List of usage examples for java.util Locale FRENCH
Locale FRENCH
To view the source code for java.util Locale FRENCH.
Click Source Link
From source file:eu.trentorise.opendata.semtext.jackson.test.SemTextModuleTest.java
@Test public void testMapper() throws IOException { SemTextModule.registerMetadata(Meaning.class, "a", Dict.class); SemTextModule.registerMetadata(Meaning.class, "b", Dict.class); SemTextModule.registerMetadata(Term.class, "c", Integer.class); SemTextModule.registerMetadata(Sentence.class, "a", MyMetadata.class); SemTextModule.registerMetadata(SemText.class, "a", Integer.class); objectMapper.registerModule(new SimpleModule() { {/*from w ww . j av a 2 s .com*/ setMixInAnnotation(MyMetadata.class, MyMetadataJackson.class); } }); try { objectMapper.readValue("{\"start\":2, \"end\":1}", Term.class); Assert.fail("Should have failed because of missing attributes!"); } catch (Exception ex) { } Meaning m1 = Meaning.of("a", MeaningKind.ENTITY, 0.2, Dict.of(Locale.ITALIAN, "a"), Dict.of(Locale.FRENCH, "b"), ImmutableMap.of("a", Dict.of("s"))); Meaning m2 = Meaning.of("b", MeaningKind.ENTITY, 0.2, Dict.of(Locale.ITALIAN, "a"), Dict.of(Locale.FRENCH, "b"), ImmutableMap.of("b", Dict.of("s"))); testJsonConv(objectMapper, LOG, Meaning.of("a", MeaningKind.CONCEPT, 0.2)); Term term = Term.of(0, 2, MeaningStatus.SELECTED, m1, ImmutableList.of(m1, m2), ImmutableMap.of("c", 3)); testJsonConv(objectMapper, LOG, SemText.ofSentences(Locale.ITALIAN, "abcdefghilmno", ImmutableList.of( Sentence.of(0, 7, ImmutableList.of(term), ImmutableMap.of("a", MyMetadata.of("hello")))), ImmutableMap.of("a", 9))); }
From source file:com.thejustdo.servlet.CargaMasivaServlet.java
/** * Processes requests for both HTTP/* ww w. ja v a 2s .c om*/ * <code>GET</code> and * <code>POST</code> methods. * * @param request servlet request * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { log.info(String.format("Welcome to the MULTI-PART!!!")); ResourceBundle messages = ResourceBundle.getBundle("com.thejustdo.resources.messages"); // 0. If no user logged, nothing can be done. if (!SecureValidator.checkUserLogged(request, response)) { return; } // 1. Check that we have a file upload request. boolean isMultipart = ServletFileUpload.isMultipartContent(request); log.info(String.format("Is multipart?: %s", isMultipart)); // 2. Getting all the parameters. String social_reason = request.getParameter("razon_social"); String nit = request.getParameter("nit"); String name = request.getParameter("name"); String phone = request.getParameter("phone"); String email = request.getParameter("email"); String office = (String) request.getSession().getAttribute("actualOffice"); String open_amount = (String) request.getParameter("valor_tarjeta"); String open_user = (String) request.getSession().getAttribute("actualUser"); List<String> errors = new ArrayList<String>(); // 6. Create a factory for disk-based file items DiskFileItemFactory factory = new DiskFileItemFactory(); // 7. Configure a repository (to ensure a secure temp location is used) ServletContext servletContext = this.getServletConfig().getServletContext(); File repository = (File) servletContext.getAttribute("javax.servlet.context.tempdir"); log.info(String.format("Temporal repository: %s", repository.getAbsolutePath())); factory.setRepository(repository); // 8. Create a new file upload handler ServletFileUpload upload = new ServletFileUpload(factory); try { utx.begin(); EntityManager em = emf.createEntityManager(); // Parse the request List<FileItem> items = upload.parseRequest(request); // 8.0 A set of generated box codes must be maintained. Map<String, String> matrix = new HashMap<String, String>(); // ADDED: Validation 'o file extension. String filename = null; // Runing through the parameters. for (FileItem fi : items) { if (fi.isFormField()) { if ("razon_social".equalsIgnoreCase(fi.getFieldName())) { social_reason = fi.getString(); continue; } if ("nit".equalsIgnoreCase(fi.getFieldName())) { nit = fi.getString(); continue; } if ("name".equalsIgnoreCase(fi.getFieldName())) { name = fi.getString(); continue; } if ("phone".equalsIgnoreCase(fi.getFieldName())) { phone = fi.getString(); continue; } if ("email".equalsIgnoreCase(fi.getFieldName())) { email = fi.getString(); continue; } if ("valor_tarjeta".equalsIgnoreCase(fi.getFieldName())) { open_amount = fi.getString(); continue; } } else { filename = fi.getName(); } } // 3. If we got no file, then a error is generated and re-directed to the exact same page. if (!isMultipart) { errors.add(messages.getString("error.massive.no_file")); log.log(Level.SEVERE, errors.toString()); } // 4. If any of the others paramaeters are missing, then a error must be issued. if ((social_reason == null) || ("".equalsIgnoreCase(social_reason.trim()))) { errors.add(messages.getString("error.massive.no_social_reason")); log.log(Level.SEVERE, errors.toString()); } if ((nit == null) || ("".equalsIgnoreCase(nit.trim()))) { errors.add(messages.getString("error.massive.no_nit")); log.log(Level.SEVERE, errors.toString()); } if ((name == null) || ("".equalsIgnoreCase(name.trim()))) { errors.add(messages.getString("error.massive.no_name")); log.log(Level.SEVERE, errors.toString()); } if ((phone == null) || ("".equalsIgnoreCase(phone.trim()))) { errors.add(messages.getString("error.massive.no_phone")); log.log(Level.SEVERE, errors.toString()); } if ((email == null) || ("".equalsIgnoreCase(email.trim()))) { errors.add(messages.getString("error.massive.no_email")); log.log(Level.SEVERE, errors.toString()); } // If no filename or incorrect extension. if ((filename == null) || (!(filename.endsWith(Constants.MASSIVE_EXT.toLowerCase(Locale.FRENCH))) && !(filename.endsWith(Constants.MASSIVE_EXT.toUpperCase())))) { errors.add(messages.getString("error.massive.invalid_ext")); log.log(Level.SEVERE, errors.toString()); } // 5. If any errors found, we must break the flow. if (errors.size() > 0) { request.setAttribute(Constants.ERROR, errors); //Redirect the response request.getRequestDispatcher("/WEB-INF/jsp/carga_masiva.jsp").forward(request, response); } for (FileItem fi : items) { if (!fi.isFormField()) { // 8.1 Processing the file and building the Beneficiaries. List<Beneficiary> beneficiaries = processFile(fi); log.info(String.format("Beneficiaries built: %d", beneficiaries.size())); // 8.2 If any beneficiaries, then an error is generated. if ((beneficiaries == null) || (beneficiaries.size() < 0)) { errors.add(messages.getString("error.massive.empty_file")); log.log(Level.SEVERE, errors.toString()); request.setAttribute(Constants.ERROR, errors); //Redirect the response request.getRequestDispatcher("/WEB-INF/jsp/carga_masiva.jsp").forward(request, response); } // 8.3 Building main parts. Buyer b = buildGeneralBuyer(em, social_reason, nit, name, phone, email); // 8.3.1 The DreamBox has to be re-newed per beneficiary. DreamBox db; for (Beneficiary _b : beneficiaries) { // 8.3.2 Completing each beneficiary. log.info(String.format("Completying the beneficiary: %d", _b.getIdNumber())); db = buildDreamBox(em, b, office, open_amount, open_user); matrix.put(db.getNumber() + "", _b.getGivenNames() + " " + _b.getLastName()); _b.setOwner(b); _b.setBox(db); em.merge(_b); } } } // 8.4 Commiting to persistence layer. utx.commit(); // 8.5 Re-directing to the right jsp. request.getSession().setAttribute("boxes", matrix); request.getSession().setAttribute("boxamount", open_amount + ""); //Redirect the response generateZIP(request, response); } catch (Exception ex) { errors.add(messages.getString("error.massive.couldnot_process")); log.log(Level.SEVERE, errors.toString()); request.setAttribute(Constants.ERROR, errors); request.getRequestDispatcher("/WEB-INF/jsp/carga_masiva.jsp").forward(request, response); } }
From source file:fr.paris.lutece.plugins.dila.modules.solr.utils.parsers.DilaSolrPublicParser.java
/** * Event received at the end of the parsing operation * * @throws SAXException any SAX exception *//*from w w w. j a va 2 s . c o m*/ public void endDocument() throws SAXException { // Sets the ID // Sets the full URL UrlItem url = new UrlItem(_strProdUrl); url.addParameter(XPageAppService.PARAM_XPAGE_APP, AppPropertiesService.getProperty(PROPERTY_PLUGIN_NAME)); url.addParameter(AppPropertiesService.getProperty(PROPERTY_PATH_ID), _strId); url.addParameter(AppPropertiesService.getProperty(PROPERTY_PATH_CATEGORY), _strAudience); // Converts the date from "dd MMMMM yyyy" to "yyyyMMdd" Locale locale = Locale.FRENCH; Date dateUpdate = null; if (StringUtils.isNotEmpty(_strDate)) { try { SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd", locale); String strDate = _strDate.split(STRING_SPACE)[1]; dateUpdate = dateFormat.parse(strDate); dateFormat.applyPattern("yyyyMMdd"); } catch (ParseException e) { dateUpdate = null; } } else { dateUpdate = null; } if (StringUtils.isNotEmpty(_strId)) { // Creates a new lucene document SolrItem item = new SolrItem(); item.setUrl(url.getUrl()); item.setDate(dateUpdate); item.setUid(_strId); item.setContent(_strContents); item.setTitle(_strTitle); item.setType(_strType); item.setSite(_strSite); String[] categories = new String[] { _strAudience }; item.setCategorie(Arrays.asList(categories)); // Adds the new item to the list _listSolrItems.add(item); } }
From source file:com.doculibre.constellio.lucene.impl.SkosIndexHelperImpl.java
@Override public void add(Thesaurus thesaurus) { delete(thesaurus);/*from w ww .j av a2 s . c om*/ try { Directory directory = FSDirectory.open(getIndexDir()); Analyzer analyzer = getAnalyzerProvider().getAnalyzer(Locale.FRENCH); IndexWriter indexWriter = new IndexWriter(directory, new IndexWriterConfig(Version.LUCENE_44, analyzer)); List<SkosConcept> skosConcepts = new ArrayList<SkosConcept>(); for (SkosConcept topConcept : thesaurus.getTopConcepts()) { addConceptAndSubConcepts(topConcept, skosConcepts); } for (SkosConcept skosConcept : skosConcepts) { add(skosConcept, indexWriter); } // indexWriter.optimize(); indexWriter.close(); directory.close(); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:fr.mcc.ginco.soap.SOAPThesaurusTermServiceImpl.java
@Override public List<ReducedThesaurusTerm> getTermsBeginWithSomeStringByThesaurus(String request, String thesaurusId, Boolean preferredTermOnly, int startIndex, int limit, TermStatusEnum status, Boolean withNotes) { if (StringUtils.isNotEmpty(request) && limit != 0) { try {//w ww .ja v a 2 s . c o m request = ClientUtils.escapeQueryChars(request); String requestFormat = SolrField.LEXICALVALUE_STR + ":" + request + "*"; List<ReducedThesaurusTerm> reducedThesaurusTermList = new ArrayList<ReducedThesaurusTerm>(); SortCriteria crit = new SortCriteria(SolrField.LEXICALVALUE, SolrConstants.ASCENDING); Integer searchType = SearchEntityType.TERM; if (preferredTermOnly) { searchType = SearchEntityType.TERM_PREF; } Integer intStatus = null; if (status != null) { intStatus = status.getStatus(); } SearchResultList searchResultList = searcherService.search(requestFormat, searchType, thesaurusId, intStatus, null, null, null, crit, startIndex, limit); if (searchResultList != null) { for (SearchResult searchResult : searchResultList) { ReducedThesaurusTerm reducedThesaurusTerm = new ReducedThesaurusTerm(); reducedThesaurusTerm.setIdentifier(searchResult.getIdentifier()); reducedThesaurusTerm.setConceptId(searchResult.getConceptId()); reducedThesaurusTerm.setLexicalValue(searchResult.getLexicalValue()); reducedThesaurusTerm.setLanguageId(searchResult.getLanguages().get(0)); reducedThesaurusTerm.setStatus(TermStatusEnum.getStatusByCode(searchResult.getStatus())); if (withNotes != null && withNotes == true) { addNotesToTerm(reducedThesaurusTerm); } reducedThesaurusTermList.add(reducedThesaurusTerm); } } Collections.sort(reducedThesaurusTermList, new Comparator<ReducedThesaurusTerm>() { Collator frCollator = Collator.getInstance(Locale.FRENCH); public int compare(ReducedThesaurusTerm t1, ReducedThesaurusTerm t2) { return frCollator.compare(t1.getLexicalValue(), t2.getLexicalValue()); } }); return reducedThesaurusTermList; } catch (SolrServerException e) { throw new TechnicalException("Search exception", e); } } else { throw new BusinessException("One or more parameters are empty", "empty-parameters"); } }
From source file:org.yccheok.jstock.gui.Utils.java
/** * Returns true if there are specified language files designed for this * locale. As in Java, when there are no specified language files for a * locale, a default language file will be used. * /*w w w .j a v a2 s .com*/ * @param locale the locale * @return true if there are specified language files designed for this * locale */ public static boolean hasSpecifiedLanguageFile(Locale locale) { // Please revise Statement's construct code, when adding in new language. // So that its language guessing algorithm will work as it is. if (Utils.isTraditionalChinese(locale)) { return true; } else if (Utils.isSimplifiedChinese(locale)) { return true; } else if (locale.getLanguage().equals(Locale.GERMAN.getLanguage())) { return true; } else if (locale.getLanguage().equals(Locale.ENGLISH.getLanguage())) { return true; } else if (locale.getLanguage().equals(Locale.ITALIAN.getLanguage())) { return true; } else if (locale.getLanguage().equals(Locale.FRENCH.getLanguage())) { return true; } return false; }
From source file:org.marketcetera.util.ws.wrappers.WrapperTestBase.java
protected static void assertThrowable(Throwable expected, Throwable actual, boolean proxyUsed) { if ((actual == null) || (expected == null)) { assertEquals(expected, actual);/*from w w w . ja va 2s. c o m*/ return; } if (proxyUsed) { assertEquals(RemoteProxyException.class, actual.getClass()); if (expected instanceof I18NThrowable) { assertEquals(((I18NThrowable) expected).getLocalizedDetail(), actual.getMessage()); ActiveLocale.setProcessLocale(Locale.FRENCH); assertEquals(((I18NThrowable) expected).getLocalizedDetail(), actual.getMessage()); ActiveLocale.setProcessLocale(Locale.ROOT); } else { assertEquals(expected.getLocalizedMessage(), actual.getMessage()); } } else { assertEquals(expected.getClass(), actual.getClass()); assertEquals(expected.getMessage(), actual.getMessage()); } assertEquals(expected.toString(), actual.toString()); assertArrayEquals(ExceptionUtils.getStackFrames(expected), ExceptionUtils.getStackFrames(actual)); }
From source file:com.doculibre.constellio.lucene.BaseLuceneIndexHelper.java
protected synchronized int getDocNum(T object) { int docNum;/*from w w w . j av a 2 s . c o m*/ String uniqueIndexFieldName = getUniqueIndexFieldName(); String uniqueIndexFieldValue = getUniqueIndexFieldValue(object); if (uniqueIndexFieldValue != null) { String query = uniqueIndexFieldName + ":" + uniqueIndexFieldValue; try { Analyzer analyzer = analyzerProvider.getAnalyzer(Locale.FRENCH); QueryParser multiFielsQP = new QueryParser(Version.LUCENE_44, uniqueIndexFieldName, analyzer); Query luceneQuery = multiFielsQP.parse(query); Directory directory = FSDirectory.open(indexDir); IndexReader reader = DirectoryReader.open(directory); IndexSearcher indexSearcher = new IndexSearcher(reader); TopDocs topDocs = indexSearcher.search(luceneQuery, reader.maxDoc()); if (topDocs.totalHits > 0) { docNum = topDocs.scoreDocs[0].doc; } else { docNum = -1; } // indexSearcher.close(); // TODO add finally reader.close(); directory.close(); } catch (ParseException e) { throw new RuntimeException(e); } catch (CorruptIndexException e) { throw new RuntimeException(e); } catch (IOException e) { throw new RuntimeException(e); } } else { docNum = -1; } return docNum; }
From source file:org.opencommercesearch.SearchServerManager.java
/** * Initializes the read only search server. The ro server is a singleton. * If the tests are configured to run in parallel multiple JVMs will be spawn and each will * have its own read only server./* ww w.ja va 2 s . com*/ * * The default data xml files are: * * catalog: /product_catalog/bootstrap_en.xml * rules: /rules/bootstrap_en.xml */ public void initServer(boolean loadBootstrapData) { initServerAux(loadBootstrapData, loadXmlResource("/product_catalog/bootstrap_en.xml"), loadXmlResource("/rules/bootstrap_en.xml"), null, null); try { searchServer.updateCollection(searchServer.getCatalogCollection(), loadXmlResource("/product_catalog/bootstrap_fr.xml"), Locale.FRENCH); searchServer.updateCollection(searchServer.getRulesCollection(), loadXmlResource("/rules/bootstrap_fr.xml"), Locale.FRENCH); } catch (SolrServerException ex) { throw new RuntimeException(ex); } catch (IOException ex) { throw new RuntimeException(ex); } }
From source file:fr.paris.lutece.plugins.workflow.modules.ticketing.service.task.TaskEditTicket.java
/** * Process the task for agent side//from w w w . j a v a2 s .c om * @param nIdResourceHistory the ResourceHistory id * @param request the request * @param locale the locale * @param config the task configuration * @return the information message to store */ private String processAgentTask(int nIdResourceHistory, HttpServletRequest request, Locale locale, TaskEditTicketConfig config) { String strTaskInformation = StringUtils.EMPTY; String strAgentMessage = request.getParameter(PARAMETER_MESSAGE + UNDERSCORE + getId()); String[] listIdsEntry = request.getParameterValues(PARAMETER_IDS_ENTRY + UNDERSCORE + getId()); // We get the ticket to modify Ticket ticket = getTicket(nIdResourceHistory); boolean bCreate = false; List<EditableTicketField> listEditableTicketFields = new ArrayList<EditableTicketField>(); EditableTicket editableTicket = _editableTicketService.find(nIdResourceHistory, getId()); if (editableTicket == null) { editableTicket = new EditableTicket(); editableTicket.setIdHistory(nIdResourceHistory); editableTicket.setIdTask(getId()); editableTicket.setIdTicket(ticket.getId()); bCreate = true; } StringBuilder sbEntries = new StringBuilder(); if (listIdsEntry != null) { for (String strIdEntry : listIdsEntry) { if (StringUtils.isNotBlank(strIdEntry) && StringUtils.isNumeric(strIdEntry)) { int nIdEntry = Integer.parseInt(strIdEntry); EditableTicketField editableTicketField = new EditableTicketField(); editableTicketField.setIdEntry(nIdEntry); listEditableTicketFields.add(editableTicketField); Entry entry = EntryHome.findByPrimaryKey(nIdEntry); sbEntries.append(entry.getTitle()).append(SEPARATOR); } } if (sbEntries.length() != 0) { sbEntries.delete(sbEntries.length() - SEPARATOR.length(), sbEntries.length()); } } editableTicket.setMessage(StringUtils.isNotBlank(strAgentMessage) ? strAgentMessage : StringUtils.EMPTY); editableTicket.setListEditableTicketFields(listEditableTicketFields); editableTicket.setIsEdited(false); if (bCreate) { _editableTicketService.create(editableTicket); } else { _editableTicketService.update(editableTicket); } if (ticket != null) { ticket.setUrl(buildEditUrl(request, nIdResourceHistory, getId(), config.getIdUserEditionAction())); TicketHome.update(ticket); } if (sbEntries.length() == 0) { strTaskInformation = MessageFormat.format(I18nService.getLocalizedString( MESSAGE_EDIT_TICKET_INFORMATION_VIEW_AGENT_NO_FIELD_EDITED, Locale.FRENCH), strAgentMessage); } else { strTaskInformation = MessageFormat.format( I18nService.getLocalizedString(MESSAGE_EDIT_TICKET_INFORMATION_VIEW_AGENT, Locale.FRENCH), sbEntries.toString(), strAgentMessage); } return strTaskInformation; }