List of usage examples for java.util Locale getCountry
public String getCountry()
From source file:org.openmrs.Concept.java
/** * Gets the explicitly specified short name for a locale. * /* w w w.j a va2s .c om*/ * @param locale locale for which to find a short name * @return the short name, or null if none has been explicitly set */ public ConceptName getShortNameInLocale(Locale locale) { ConceptName bestMatch = null; if (locale != null && getShortNames().size() > 0) { for (ConceptName shortName : getShortNames()) { Locale nameLocale = shortName.getLocale(); if (nameLocale.equals(locale)) { return shortName; } // test for partially locale match - any language matches takes precedence over country matches. if (OpenmrsUtil.nullSafeEquals(locale.getLanguage(), nameLocale.getLanguage())) { bestMatch = shortName; } else if (bestMatch == null && StringUtils.isNotBlank(locale.getCountry()) && locale.getCountry().equals(nameLocale.getCountry())) { bestMatch = shortName; } } } return bestMatch; }
From source file:org.apache.myfaces.application.ApplicationImpl.java
@Override public final void setDefaultLocale(final Locale locale) { checkNull(locale, "locale"); _defaultLocale = locale;//from w ww . j a v a2 s.c om if (log.isLoggable(Level.FINEST)) { log.finest("set defaultLocale = " + locale.getCountry() + " " + locale.getLanguage()); } }
From source file:net.www_eee.portal.channels.ProxyChannel.java
/** * Construct the value for the "Accept-Language" header to be * {@link HttpUriRequest#setHeader(String, String) set} on the {@link HttpUriRequest} being used to * {@linkplain #createProxyRequest(Page.Request, Channel.Mode, CloseableHttpClient) proxy} content to the * <code>proxiedFileURL</code> . This method basically just fowards the * {@link javax.ws.rs.core.HttpHeaders#getAcceptableLanguages() acceptable} to the client. * //from ww w . j a v a2 s . c om * @param pageRequest The {@link net.www_eee.portal.Page.Request Request} currently being processed. * @param mode The {@link net.www_eee.portal.Channel.Mode Mode} of the request. * @param proxyClient The {@link #createProxyClient(Page.Request) HttpClient} performing the proxy request. * @param proxiedFileURL The {@linkplain #getProxiedFileURL(Page.Request, Channel.Mode, boolean) proxied file URL}. * @param proxyRequest The proxy {@link #createProxyRequestObject(Page.Request, Channel.Mode, URL) HttpUriRequest} * object. * @return The "Accept-Language" header value. * @throws WWWEEEPortal.Exception If a problem occurred while determining the result. * @throws WebApplicationException If a problem occurred while determining the result. * @see javax.ws.rs.core.HttpHeaders#getAcceptableLanguages() * @see #createProxyRequest(Page.Request, Channel.Mode, CloseableHttpClient) */ protected @Nullable String getProxyRequestAcceptLanguageHeader(final Page.Request pageRequest, final Mode mode, final HttpClient proxyClient, final URL proxiedFileURL, final HttpUriRequest proxyRequest) throws WWWEEEPortal.Exception, WebApplicationException { final List<Locale> acceptableLanguages = pageRequest.getHttpHeaders().getAcceptableLanguages(); if ((acceptableLanguages == null) || (acceptableLanguages.isEmpty())) return null; final StringBuffer acceptLanguage = new StringBuffer(); for (Locale locale : acceptableLanguages) { if (acceptLanguage.length() > 0) acceptLanguage.append(','); acceptLanguage.append(locale.getLanguage()); if (!locale.getCountry().isEmpty()) { acceptLanguage.append('-'); acceptLanguage.append(locale.getCountry()); } } return acceptLanguage.toString(); }
From source file:edu.ku.brc.ui.UIHelper.java
/** * @param locale// w w w . ja v a2 s .c om * @param fileName * @return */ public static String createLocaleName(final Locale locale, final String fileName, final String ext) { String name = fileName + '_' + locale.getLanguage(); if (StringUtils.isNotEmpty(locale.getCountry())) { name += '_' + locale.getCountry(); } String fullPath = name + '.' + ext; File file = new File(fullPath); if (file.exists()) { return name; } fullPath = fileName + '_' + locale.getLanguage() + '.' + ext; file = new File(name); if (!file.exists()) { fullPath = fileName + '.' + ext; } return fullPath; }
From source file:com.ifoer.expeditionphone.MainActivity.java
protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().setFlags(Flags.FLAG8, Flags.FLAG8); contexts = this; this.loadSpecail = getIntent().getBooleanExtra("loadSpecail", false); FROMPATH = Constant.assestsPath;// ww w . java 2 s . com Locale locale = Locale.getDefault(); country = MainMenuActivity.country; if (country == null) { country = locale.getCountry(); } this.lanName = AndroidToLan.toLan(country); this.language = locale.getLanguage(); Constant.language = locale.toString(); if (this.loadSpecail) { setContentView(C0136R.layout.specia_function2); this.SpecialGridView = (GridView) findViewById(C0136R.id.main_WorkSpace); this.SpecialGridView.setHorizontalSpacing(15); this.SpecialGridView.setVerticalSpacing(15); this.SpecialGridView.setSelector(C0136R.color.transparent); this.SpecialGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mSpecilaBaseDiagAdapeter = createBaseDiagAdapter2(this.specialList); this.SpecialGridView.setAdapter(this.mSpecilaBaseDiagAdapeter); this.SpecialGridView.setOnItemClickListener(this); } else { setContentView(C0136R.layout.base_diagnose); LinearLayout lineLinear = (LinearLayout) findViewById(C0136R.id.diagnose_line2); this.mSlidePoinView = new SlidePointView(this); lineLinear.addView(this.mSlidePoinView); this.mSlidePoinView.postInvalidate(); this.mChinaCarGridView = new GridView(this); this.mAsiaCarGridView = new GridView(this); this.mEuroCarGridView = new GridView(this); this.mAmericaCarGridView = new GridView(this); this.mAmericaCarGridView.setHorizontalSpacing(15); this.mAmericaCarGridView.setVerticalSpacing(15); this.mAsiaCarGridView.setHorizontalSpacing(15); this.mAsiaCarGridView.setVerticalSpacing(15); this.mEuroCarGridView.setHorizontalSpacing(15); this.mEuroCarGridView.setVerticalSpacing(15); this.mAmericaCarGridView.setVerticalScrollBarEnabled(false); this.mAsiaCarGridView.setVerticalScrollBarEnabled(false); this.mEuroCarGridView.setVerticalScrollBarEnabled(false); this.mAsiaCarGridView.setSelector(C0136R.color.transparent); this.mEuroCarGridView.setSelector(C0136R.color.transparent); this.mAmericaCarGridView.setSelector(C0136R.color.transparent); LayoutParams linearParams = new LayoutParams(-2, -2); linearParams.width = C0136R.dimen.itemSize; linearParams.height = C0136R.dimen.itemSize; this.mChinaCarGridView.setLayoutParams(linearParams); this.mAsiaCarGridView.setLayoutParams(linearParams); this.mEuroCarGridView.setLayoutParams(linearParams); this.mAmericaCarGridView.setLayoutParams(linearParams); this.mChinaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mAsiaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mEuroCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); this.mAmericaCarGridView.setNumColumns(REQUEST_CIRCLE_ADD_IMAGE); } MyApplication.getInstance().addActivity(this); createMainActivity(); MySharedPreferences.getSharedPref(this).edit().putString("CurrentPosition", Constant.language).commit(); MySharedPreferences.setString(contexts, MySharedPreferences.generateOperatingRecord, Contact.RELATION_ASK); if (MainMenuActivity.database != null) { database = MainMenuActivity.database; } else { database = DBDao.getInstance(this).getConnection(); } new Thread(new UpgradeRunnable(contexts)).start(); registerBoradcastReceiver(); try { dataDir = getPackageManager().getApplicationInfo(getPackageName(), 0).dataDir; } catch (NameNotFoundException e) { e.printStackTrace(); } try { serialPort = new SerialPortManager().getSerialPort(); } catch (InvalidParameterException e2) { e2.printStackTrace(); } catch (SecurityException e3) { e3.printStackTrace(); } catch (Exception e4) { e4.printStackTrace(); } if (MySharedPreferences.share == null) { MySharedPreferences.getSharedPref(this); } }
From source file:net.yacy.cora.document.id.MultiProtocolURL.java
public Locale getLocale() { if (this.hostAddress != null) { final Locale locale = Domains.getLocale(this.hostAddress); if (locale != null && locale.getCountry() != null && locale.getCountry().length() > 0) return locale; }/*from ww w . j av a2 s. c o m*/ /* if (this.hostAddress != null) { return Domains.getLocale(this.hostAddress); } */ return Domains.getLocale(this.host); }
From source file:org.oscarehr.casemgmt.web.CaseManagementViewAction.java
public ActionForward view(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception { // response.setCharacterEncoding("UTF-8"); long start = System.currentTimeMillis(); long beginning = start; long current = 0; CaseManagementViewFormBean caseForm = (CaseManagementViewFormBean) form; boolean useNewCaseMgmt = false; String useNewCaseMgmtString = (String) request.getSession().getAttribute("newCaseManagement"); if (useNewCaseMgmtString != null) useNewCaseMgmt = Boolean.parseBoolean(useNewCaseMgmtString); logger.debug("Starting VIEW"); String tab = request.getParameter("tab"); if (tab == null) { tab = CaseManagementViewFormBean.tabs[0]; }//w ww . j a v a 2 s . c o m HttpSession se = request.getSession(); if (se.getAttribute("userrole") == null) return mapping.findForward("expired"); LoggedInInfo loggedInInfo = LoggedInInfo.loggedInInfo.get(); String demoNo = getDemographicNo(request); logger.debug("is client in program"); // need to check to see if the client is in our program domain // if not...don't show this screen! String roles = (String) se.getAttribute("userrole"); if (OscarProperties.getInstance().isOscarLearning() && roles != null && roles.indexOf("moderator") != -1) { logger.info("skipping domain check..provider is a moderator"); } else if (!caseManagementMgr.isClientInProgramDomain(loggedInInfo.loggedInProvider.getProviderNo(), demoNo)) { return mapping.findForward("domain-error"); } current = System.currentTimeMillis(); logger.debug("client in program " + String.valueOf(current - start)); start = current; request.setAttribute("casemgmt_demoName", getDemoName(demoNo)); request.setAttribute("casemgmt_demoAge", getDemoAge(demoNo)); request.setAttribute("casemgmt_demoDOB", getDemoDOB(demoNo)); request.setAttribute("demographicNo", demoNo); logger.debug("client Image?"); // get client image ClientImage img = clientImageMgr.getClientImage(Integer.parseInt(demoNo)); if (img != null) { request.setAttribute("image_exists", "true"); } current = System.currentTimeMillis(); logger.debug("client image " + String.valueOf(current - start)); start = current; String programId = (String) request.getSession().getAttribute("case_program_id"); if (programId == null || programId.length() == 0) { programId = "0"; } if (!OscarProperties.getInstance().isCaisiLoaded()) { Program p = programDao.getProgramByName("OSCAR"); if (p != null) { programId = String.valueOf(p.getId()); request.getSession().setAttribute("case_program_id", programId); } } logger.debug("is there a tmp note?"); // check to see if there is an unsaved note // if there is see if casemanagemententry has already handled it // if it has, disregard unsaved note; if it has not then set attribute CaseManagementTmpSave tmpsavenote = this.caseManagementMgr .restoreTmpSave(loggedInInfo.loggedInProvider.getProviderNo(), demoNo, programId); if (tmpsavenote != null) { String restoring = (String) se.getAttribute("restoring"); if (restoring == null) request.setAttribute("can_restore", new Boolean(true)); else se.setAttribute("restoring", null); } current = System.currentTimeMillis(); logger.debug("tmp note " + String.valueOf(current - start)); start = current; logger.debug("Get admission"); String teamName = ""; Admission admission = admissionMgr.getCurrentAdmission(programId, Integer.valueOf(demoNo)); current = System.currentTimeMillis(); logger.debug("Get admission " + String.valueOf(current - start)); start = current; if (admission != null) { logger.debug("Get teams"); List teams = programMgr.getProgramTeams(programId); current = System.currentTimeMillis(); logger.debug("Get teams " + String.valueOf(current - start)); start = current; for (Iterator i = teams.iterator(); i.hasNext();) { logger.debug("Searching teams"); ProgramTeam team = (ProgramTeam) i.next(); String id1 = Integer.toString(team.getId()); String id2 = Integer.toString(admission.getTeamId()); if (id1.equals(id2)) teamName = team.getName(); } } request.setAttribute("teamName", teamName); if (OscarProperties.getInstance().isCaisiLoaded() && !useNewCaseMgmt) { logger.debug("Get program providers"); List<String> teamMembers = new ArrayList<String>(); List<ProgramProvider> ps = programMgr.getProgramProviders(programId); current = System.currentTimeMillis(); logger.debug("Get program providers " + String.valueOf(current - start)); start = current; for (Iterator<ProgramProvider> j = ps.iterator(); j.hasNext();) { ProgramProvider pp = j.next(); logger.debug("Get program provider teams"); for (Iterator<ProgramTeam> k = pp.getTeams().iterator(); k.hasNext();) { ProgramTeam pt = k.next(); if (pt.getName().equals(teamName)) { teamMembers.add(pp.getProvider().getFormattedName()); } } current = System.currentTimeMillis(); logger.debug("Get program provider teams " + String.valueOf(current - start)); start = current; } request.setAttribute("teamMembers", teamMembers); /* prepare new form list for patient */ EncounterFormDao encounterFormDao = (EncounterFormDao) SpringUtils.getBean("encounterFormDao"); se.setAttribute("casemgmt_newFormBeans", encounterFormDao.findAll()); /* prepare messenger list */ se.setAttribute("casemgmt_msgBeans", this.caseManagementMgr.getMsgBeans(new Integer(demoNo))); // readonly access to define creat a new note button in jsp. se.setAttribute("readonly", new Boolean(this.caseManagementMgr.hasAccessRight("note-read-only", "access", loggedInInfo.loggedInProvider.getProviderNo(), demoNo, (String) se.getAttribute("case_program_id")))); } /* Dx */ List<Dxresearch> dxList = this.caseManagementMgr.getDxByDemographicNo(demoNo); Map<String, Dxresearch> dxMap = new HashMap<String, Dxresearch>(); for (Dxresearch dx : dxList) { dxMap.put(dx.getDxresearchCode(), dx); } request.setAttribute("dxMap", dxMap); // UCF logger.debug("Fetch Survey List"); request.setAttribute("survey_list", surveyMgr.getAllFormsForCurrentProviderAndCurrentFacility()); current = System.currentTimeMillis(); logger.debug("Fetch Survey List " + String.valueOf(current - start)); /* ISSUES */ if (tab.equals("Current Issues")) { if (useNewCaseMgmt) viewCurrentIssuesTab_newCme(request, caseForm, demoNo, programId); else viewCurrentIssuesTab_oldCme(request, caseForm, demoNo, programId); } // end Current Issues Tab logger.debug("Get CPP"); current = System.currentTimeMillis(); CaseManagementCPP cpp = this.caseManagementMgr.getCPP(this.getDemographicNo(request)); if (cpp == null) { cpp = new CaseManagementCPP(); cpp.setDemographic_no(getDemographicNo(request)); } request.setAttribute("cpp", cpp); caseForm.setCpp(cpp); current = System.currentTimeMillis(); logger.debug("Get CPP " + String.valueOf(current - start)); start = current; /* get allergies */ logger.debug("Get Allergies"); List allergies = this.caseManagementMgr.getAllergies(this.getDemographicNo(request)); request.setAttribute("Allergies", allergies); current = System.currentTimeMillis(); logger.debug("Get Allergies " + String.valueOf(current - start)); start = current; /* get prescriptions */ if (tab.equals("Prescriptions")) { List<Drug> prescriptions = null; boolean viewAll = caseForm.getPrescipt_view().equals("all"); String demographicId = getDemographicNo(request); request.setAttribute("isIntegratorEnabled", LoggedInInfo.loggedInInfo.get().currentFacility.isIntegratorEnabled()); prescriptions = caseManagementMgr.getPrescriptions(ConversionUtils.fromIntString(demographicId), viewAll); request.setAttribute("Prescriptions", prescriptions); // Setup RX bean start RxSessionBean bean = new RxSessionBean(); bean.setProviderNo(loggedInInfo.loggedInProvider.getProviderNo()); bean.setDemographicNo(ConversionUtils.fromIntString(demoNo)); request.getSession().setAttribute("RxSessionBean", bean); // set up RX end } /* tickler */ if (tab != null && tab.equalsIgnoreCase("Ticklers")) { CustomFilter cf = new CustomFilter(); cf.setDemographic_no(this.getDemographicNo(request)); cf.setStatus("A"); request.setAttribute("ticklers", ticklerManager.getTicklers(cf)); } if (tab != null && tab.equalsIgnoreCase("Search")) { request.setAttribute("roles", roleMgr.getRoles()); request.setAttribute("program_domain", programMgr.getProgramDomain(getProviderNo(request))); } /* set form value for e-chart */ Locale vLocale = (Locale) se.getAttribute(org.apache.struts.Globals.LOCALE_KEY); caseForm.setVlCountry(vLocale.getCountry()); caseForm.setDemographicNo(getDemographicNo(request)); se.setAttribute("casemgmt_DemoNo", demoNo); caseForm.setRootCompURL((String) se.getAttribute("casemgmt_oscar_baseurl")); se.setAttribute("casemgmt_VlCountry", vLocale.getCountry()); // if we have just saved a note, remove saveNote flag String varName = "saveNote" + demoNo; Boolean saved = (Boolean) se.getAttribute(varName); if (saved != null && saved == true) { request.setAttribute("saveNote", saved); se.removeAttribute(varName); } current = System.currentTimeMillis(); // load up custom JavaScript // 1. try from Properties String customCmeJs = OscarProperties.getInstance().getProperty("cme_js"); if (customCmeJs == null || customCmeJs.length() == 0) { request.setAttribute("cme_js", "default"); } else { request.setAttribute("cme_js", customCmeJs); } // 2. Override from provider preferences? // 3. Override based on appointment type? logger.debug("VIEW Exiting " + String.valueOf(current - beginning)); String printPreview = (String) request.getAttribute("patientCppPrintPreview"); if ("true".equals(printPreview)) { request.setAttribute("patientCppPrintPreview", "false"); return mapping.findForward("clientHistoryPrintPreview"); } else { if (useNewCaseMgmt) { String fwdName = request.getParameter("ajaxview"); if (fwdName == null || fwdName.equals("") || fwdName.equalsIgnoreCase("null")) { return mapping.findForward("page.newcasemgmt.view"); } else { return mapping.findForward(fwdName); } } else return mapping.findForward("page.casemgmt.view"); } }
From source file:org.opencommercesearch.AbstractSearchServer.java
@Override public SearchResponse browse(BrowseOptions options, SolrQuery query, Site site, Locale locale, FilterQuery... filterQueries) throws SearchServerException { boolean hasCategoryId = StringUtils.isNotBlank(options.getCategoryId()); boolean hasCategoryPath = StringUtils.isNotBlank(options.getCategoryPath()); boolean hasBrandId = StringUtils.isNotBlank(options.getBrandId()); boolean addCategoryGraph = (options.isFetchCategoryGraph() || (hasBrandId && options.isFetchProducts() && !hasCategoryId)) && !options.isRuleBasedPage(); String categoryPath = null;/*from w w w . j a v a 2s. com*/ if (hasCategoryPath) { categoryPath = options.getCategoryPath(); } else { categoryPath = options.getCatalogId() + "."; } if (options.isRuleBasedPage()) { //handle rule based pages String filter = rulesBuilder.buildRulesFilter(options.getCategoryId(), locale); query.addFilterQuery(filter); query.setParam("q", "*:*"); } else { //handle brand, category or onsale pages if (addCategoryGraph) { query.setFacetPrefix(CATEGORY_PATH, categoryPath); query.addFacetField(CATEGORY_PATH); query.set("f.categoryPath.facet.limit", options.getMaxCategoryResults()); } if (!options.isFetchProducts()) { query.setRows(0); } List<String> queryAltParams = new ArrayList<String>(); if (hasCategoryId) { queryAltParams.add(CATEGORY_PATH + ":" + categoryPath); query.setParam("q", ""); } if (hasBrandId) { queryAltParams.add(BRAND_ID + ":" + options.getBrandId()); query.setParam("q", ""); } if (options.isOnSale()) { queryAltParams.add("onsale" + locale.getCountry() + ":true"); } if (queryAltParams.size() > 0) { query.set(Q_ALT, "(" + StringUtils.join(queryAltParams, " AND ") + ")"); } } RepositoryItem catalog = null; if (site != null) { catalog = (RepositoryItem) site.getPropertyValue("defaultCatalog"); } SearchResponse response = null; if (options.isRuleBasedPage()) { response = doSearch(query, site, catalog, locale, false, true, categoryPath, options.isOnSale(), options.getBrandId(), filterQueries); } else if (hasCategoryPath) { response = doSearch(query, site, catalog, locale, false, false, categoryPath, options.isOnSale(), options.getBrandId(), filterQueries); } else { response = doSearch(query, site, catalog, locale, false, false, null, options.isOnSale(), options.getBrandId(), filterQueries); } if (addCategoryGraph) { response.setCategoryGraph( createCategoryGraph(response, options.getCategoryPath(), options.getCatalogId(), options.getCategoryId(), options.getDepthLimit(), options.getSeparator())); } return response; }
From source file:com.salesmanager.core.service.order.OrderService.java
/** * Sends an email to the customer with minimum invoice details and an * invoice link//w w w .j ava2 s.c o m * * @param order * @param customer * @throws Exception */ public void sendEmailInvoice(MerchantStore store, Order order, Customer customer, Locale locale) throws Exception { MerchantService mservice = (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService); //MerchantUserInformation userInformation = mservice // .getMerchantUserInfo(store.getMerchantId()); CommonService cservice = (CommonService) ServiceFactory.getService(ServiceFactory.CommonService); LabelUtil lhelper = LabelUtil.getInstance(); lhelper.setLocale(locale); String subject = lhelper.getText(customer.getCustomerLang(), "label.email.invoice", store.getStorename()); // url StringBuffer url = new StringBuffer().append("<a href='").append(FileUtil.getInvoiceUrl(order, customer)) .append("&request_locale=").append(customer.getCustomerLang()).append("_") .append(locale.getCountry()).append("'>"); url.append(lhelper.getText(customer.getCustomerLang(), "label.email.invoice.viewinvoice")).append("</a>"); String emailText = lhelper.getText(customer.getCustomerLang(), "label.email.invoice.text", store.getStorename()); Map keyvalueparseableelements = new HashMap(); keyvalueparseableelements.put("EMAIL_STORE_NAME", store.getStorename()); keyvalueparseableelements.put("EMAIL_GREETING", lhelper.getText(customer.getCustomerLang(), "label.generic.greeting.hi")); keyvalueparseableelements.put("EMAIL_CUSTOMER_NAME", customer.getName()); keyvalueparseableelements.put("EMAIL_INVOICE_MESSAGE", emailText); keyvalueparseableelements.put("EMAIL_INVOICE_PAYMENT_URL", url); keyvalueparseableelements.put("EMAIL_CONTACT_OWNER", store.getStoreemailaddress()); cservice.sendHtmlEmail(customer.getCustomerEmailAddress(), subject, store, keyvalueparseableelements, "email_template_sentinvoice.ftl", customer.getCustomerLang()); OrderStatusHistory history = new OrderStatusHistory(); history.setCustomerNotified(1); history.setDateAdded(new Date()); history.setOrderId(order.getOrderId()); history.setOrderStatusId(OrderConstants.STATUSINVOICESENT); history.setComments(lhelper.getText("message.order.invoice.emailsent")); orderStatusHistoryDao.persist(history); }