List of usage examples for java.util Locale UK
Locale UK
To view the source code for java.util Locale UK.
Click Source Link
From source file:com.htmlhifive.pitalium.core.io.FilePersister.java
/** * ?????????????/*from ww w .jav a 2 s .c o m*/ * * @param file ? * @return ? */ private File checkFileAvailable(File file) { if (!file.exists()) { throw new ResourceUnavailableException(String.format(Locale.UK, "File \"%s\" not found", file)); } if (!file.canRead()) { throw new ResourceUnavailableException(String.format(Locale.UK, "File \"%s\" cannot read", file)); } return file; }
From source file:com.gtwm.pb.servlets.AppController.java
public static void carryOutAppActions(HttpServletRequest request, SessionDataInfo sessionData, DatabaseInfo databaseDefn, List<FileItem> multipartItems, StringBuffer appActionName) throws AgileBaseException, SQLException, FileUploadException, IOException, MessagingException { // perform any actions EnumSet<AppAction> appActions = EnumSet.allOf(AppAction.class); for (AppAction appAction : appActions) { // Store so exception handling has access to the action carried out appActionName.setLength(0);/* ww w . j a v a 2 s.c om*/ appActionName.append(appAction.toString()); String appActionValue = ServletUtilMethods.getParameter(request, appAction.toString().toLowerCase(Locale.UK), multipartItems); if (appActionValue != null) { sessionData.setLastAppAction(appAction); switch (appAction) { // Most commonly used actions at the start case UPDATE_RECORD: ServletDataMethods.saveRecord(sessionData, request, false, databaseDefn, multipartItems); break; case SAVE_NEW_RECORD: ServletDataMethods.saveRecord(sessionData, request, true, databaseDefn, multipartItems); break; case CLONE_RECORD: ServletDataMethods.cloneRecord(sessionData, request, databaseDefn, multipartItems); break; case REMOVE_RECORD: ServletDataMethods.removeRecord(sessionData, request, databaseDefn); break; case GLOBAL_EDIT: ServletDataMethods.globalEdit(sessionData, request, databaseDefn, multipartItems); break; case CONTRACT_SECTION: ServletSchemaMethods.contractSection(sessionData, request, databaseDefn); break; case EXPAND_SECTION: ServletSchemaMethods.expandSection(sessionData, request, databaseDefn); break; case ADD_COMMENT: ServletDataMethods.addComment(sessionData, request, databaseDefn); break; case ADD_USER: ServletAuthMethods.addUser(sessionData, request, databaseDefn.getAuthManager()); break; case REMOVE_USER: ServletAuthMethods.removeUser(sessionData, request, databaseDefn); break; case UPDATE_USER: ServletAuthMethods.updateUser(sessionData, request, databaseDefn.getAuthManager()); break; case SEND_PASSWORD_RESET: ServletAuthMethods.sendPasswordReset(request, databaseDefn.getAuthManager()); break; case ADD_ROLE: ServletAuthMethods.addRole(sessionData, request, databaseDefn.getAuthManager()); break; case UPDATE_ROLE: ServletAuthMethods.updateRole(sessionData, request, databaseDefn.getAuthManager()); break; case REMOVE_ROLE: ServletAuthMethods.removeRole(sessionData, request, databaseDefn); break; case ASSIGN_USER_TO_ROLE: ServletAuthMethods.assignUserToRole(request, databaseDefn.getAuthManager()); break; case REMOVE_USER_FROM_ROLE: ServletAuthMethods.removeUserFromRole(request, databaseDefn); break; case ADD_PRIVILEGE: ServletAuthMethods.addPrivilege(request, databaseDefn); break; case REMOVE_PRIVILEGE: ServletAuthMethods.removePrivilege(request, databaseDefn); break; case SET_MAX_TABLE_PRIVILEGE: ServletAuthMethods.setMaxTablePrivilege(sessionData, request, databaseDefn); break; case CLEAR_ALL_TABLE_PRIVILEGES: ServletAuthMethods.clearAllTablePrivileges(request, databaseDefn); break; case ADD_TABLE: ServletSchemaMethods.addTable(sessionData, request, databaseDefn); break; case UPDATE_TABLE: ServletSchemaMethods.updateTable(sessionData, request, databaseDefn); break; case REMOVE_TABLE: ServletSchemaMethods.removeTable(sessionData, request, databaseDefn); break; case ADD_FIELD: ServletSchemaMethods.addField(sessionData, request, databaseDefn); break; case REMOVE_FIELD: ServletSchemaMethods.removeField(sessionData, request, databaseDefn); break; case UPDATE_FIELD: ServletSchemaMethods.updateField(sessionData, request, databaseDefn); break; case UPDATE_FIELD_OPTION: ServletSchemaMethods.updateFieldOption(sessionData, request, databaseDefn); break; case SET_FIELD_INDEX: ServletSchemaMethods.setFieldIndex(sessionData, request, databaseDefn); break; case ADD_REPORT: ServletSchemaMethods.addReport(sessionData, request, databaseDefn); break; case UPDATE_REPORT: ServletSchemaMethods.updateReport(sessionData, request, databaseDefn); break; case UPLOAD_CUSTOM_TEMPLATE: ServletSchemaMethods.uploadCustomReportTemplate(sessionData, request, databaseDefn, multipartItems); break; case REMOVE_CUSTOM_TEMPLATE: ServletSchemaMethods.removeCustomReportTemplate(sessionData, request, databaseDefn); break; case REMOVE_REPORT: ServletSchemaMethods.removeReport(sessionData, request, databaseDefn); break; case ADD_FIELD_TO_REPORT: ServletSchemaMethods.addFieldToReport(sessionData, request, databaseDefn); break; case REMOVE_FIELD_FROM_REPORT: ServletSchemaMethods.removeFieldFromReport(sessionData, request, databaseDefn); break; case SET_REPORT_FIELD_INDEX: ServletSchemaMethods.setReportFieldIndex(sessionData, request, databaseDefn); break; case SET_REPORT_FIELD_SORTING: ServletSchemaMethods.setReportFieldSorting(sessionData, request, databaseDefn); break; case ADD_CALCULATION_TO_REPORT: ServletSchemaMethods.addCalculationToReport(sessionData, request, databaseDefn); break; case UPDATE_CALCULATION_IN_REPORT: ServletSchemaMethods.updateCalculationInReport(sessionData, request, databaseDefn); break; case ADD_FILTER_TO_REPORT: ServletSchemaMethods.addFilterToReport(sessionData, request, databaseDefn); break; case REMOVE_FILTER_FROM_REPORT: ServletSchemaMethods.removeFilterFromReport(sessionData, request, databaseDefn); break; case ADD_JOIN_TO_REPORT: ServletSchemaMethods.addJoinToReport(sessionData, request, databaseDefn); break; case REMOVE_JOIN_FROM_REPORT: ServletSchemaMethods.removeJoinFromReport(sessionData, request, databaseDefn); break; case ADD_GROUPING_TO_CHART: ServletSchemaMethods.addGroupingToChart(sessionData, request, databaseDefn); break; case REMOVE_GROUPING_FROM_CHART: ServletSchemaMethods.removeGroupingFromChart(sessionData, request, databaseDefn); break; case ADD_FUNCTION_TO_CHART: ServletSchemaMethods.addFunctionToChart(sessionData, request, databaseDefn); break; case REMOVE_FUNCTION_FROM_CHART: ServletSchemaMethods.removeFunctionFromChart(sessionData, request, databaseDefn); break; case SET_CHART_FILTER: ServletSchemaMethods.setChartFilter(sessionData, request, databaseDefn); break; case SET_CHART_FILTER_FIELD: ServletSchemaMethods.setChartFilterField(sessionData, request, databaseDefn); break; case SET_CHART_RANGE: ServletSchemaMethods.setChartRange(sessionData, request, databaseDefn); break; case SAVE_CHART: ServletSchemaMethods.saveChart(sessionData, request, databaseDefn); break; case REMOVE_CHART: ServletSchemaMethods.removeChart(sessionData, request, databaseDefn); break; case SET_WORD_CLOUD_FIELD: ServletSchemaMethods.setReportWordCloudField(sessionData, request, databaseDefn); break; case UPDATE_MAP: ServletSchemaMethods.updateMap(sessionData, request, databaseDefn); break; case SET_DASHBOARD_CHART_STATE: ServletDashboardMethods.setDashboardSummaryState(sessionData, request, databaseDefn); break; case CSV_IMPORT: ServletDataMethods.importRecords(sessionData, request, databaseDefn, multipartItems); break; case LOCK_RECORDS: ServletDataMethods.lockRecords(sessionData, request, databaseDefn); break; case ADD_COMPANY: ServletSchemaMethods.addCompany(request, databaseDefn); break; case REMOVE_COMPANY: ServletSchemaMethods.removeCompany(request, databaseDefn.getAuthManager()); break; case ANONYMISE: ServletDataMethods.anonymiseTableData(sessionData, request, databaseDefn, multipartItems); break; case ADD_MODULE: ServletSchemaMethods.addModule(request, sessionData, databaseDefn); break; case REMOVE_MODULE: ServletSchemaMethods.removeModule(request, sessionData, databaseDefn); break; case UPDATE_MODULE: ServletSchemaMethods.updateModule(request, sessionData, databaseDefn.getAuthManager()); break; case HIDE_REPORT: ServletSchemaMethods.hideReportFromUser(sessionData, request, databaseDefn); break; case UNHIDE_REPORT: ServletSchemaMethods.unhideReportFromUser(sessionData, request, databaseDefn); break; case ADD_OPERATIONAL_DASHBOARD_REPORT: ServletSchemaMethods.addOperationalDashboardReport(sessionData, request, databaseDefn); break; case REMOVE_OPERATIONAL_DASHBOARD_REPORT: ServletSchemaMethods.removeOperationalDashboardReport(sessionData, request, databaseDefn); break; case ADD_FORM_TABLE: ServletSchemaMethods.addFormTable(sessionData, request, databaseDefn); break; case REMOVE_FORM_TABLE: ServletSchemaMethods.removeFormTable(sessionData, request, databaseDefn); break; case ADD_FORM_TAB: ServletSchemaMethods.addFormTab(request, sessionData, databaseDefn); break; case REMOVE_FORM_TAB: ServletSchemaMethods.removeFormTab(request, sessionData, databaseDefn); break; case UPDATE_FORM_TAB: ServletSchemaMethods.updateFormTab(sessionData, request, databaseDefn); break; case SET_TABLE_FORM: ServletSchemaMethods.setTableForm(request, sessionData, databaseDefn); break; case SET_USER_DEFAULT_REPORT: ServletSchemaMethods.setUserDefaultReport(sessionData, request, databaseDefn); break; case SET_CALENDAR_SYNCABLE: boolean calendarSyncable = Helpers.valueRepresentsBooleanTrue(appActionValue); ServletSchemaMethods.setCalendarSyncable(sessionData, request, databaseDefn, calendarSyncable); break; case ENABLE_DISABLE_APP: ServletSchemaMethods.enableDisableApp(request, databaseDefn); break; case ADD_REPORT_DISTINCT: ServletSchemaMethods.addDistinctToReport(sessionData, request, databaseDefn); break; case REMOVE_REPORT_DISTINCT: ServletSchemaMethods.removeDistinctFromReport(sessionData, request, databaseDefn); break; } } } }
From source file:app.RunApp.java
/** * Constructor. It initializes the main features of the tool. *//*from ww w. j av a2s . c o m*/ public RunApp() { //For menus language at charts Locale.setDefault(Locale.UK); jTablePrincipal = new JTable(); jTableChiPhi = new JTable(); fixedTableChiPhi = new JTable(); fixedTableCoocurrences = new JTable(); fixedTableHeatmap = new JTable(); jTableCoocurrences = new JTable(); jTableHeatmap = new JTable(); jTableMulti = new JTable(); this.setTitle("Multi-Label Dataset Analyzer (MLDA)"); try { this.setIconImage(ImageIO.read(new File("src/images/64.png"))); } catch (IOException exc) { } this.setMinimumSize(new Dimension(780, 500)); this.setBounds(300, 0, 780, 500); initComponents(); initConfig(); datasetCurrentName = ""; multipleDatasetsConfig(); }
From source file:org.jfree.data.time.TimeSeriesCollectionTest.java
@Test public void testGetRangeBounds2() { TimeZone tzone = TimeZone.getTimeZone("Europe/London"); Calendar calendar = new GregorianCalendar(tzone, Locale.UK); calendar.clear();//w ww.j a va 2 s.c om calendar.set(2014, Calendar.FEBRUARY, 23, 6, 0); long start = calendar.getTimeInMillis(); calendar.clear(); calendar.set(2014, Calendar.FEBRUARY, 24, 18, 0); long end = calendar.getTimeInMillis(); Range range = new Range(start, end); TimeSeriesCollection collection = new TimeSeriesCollection(tzone); assertNull(collection.getRangeBounds(Collections.EMPTY_LIST, range, true)); TimeSeries s1 = new TimeSeries("S1"); s1.add(new Day(24, 2, 2014), 10.0); collection.addSeries(s1); assertEquals(new Range(10.0, 10.0), collection.getRangeBounds(Arrays.asList("S1"), range, true)); collection.setXPosition(TimePeriodAnchor.MIDDLE); assertEquals(new Range(10.0, 10.0), collection.getRangeBounds(Arrays.asList("S1"), range, true)); collection.setXPosition(TimePeriodAnchor.END); assertNull(collection.getRangeBounds(Arrays.asList("S1"), range, true)); }
From source file:org.talend.dataquality.standardization.phone.PhoneNumberHandlerBaseTest.java
@Test public void testGetCarrierNameForNumber() { assertEquals(StringUtils.EMPTY,/* ww w. j ava2 s . c o m*/ phoneNumberHandlerBase.getCarrierNameForNumber(CN_NUM_1, REGCODE_CN, Locale.SIMPLIFIED_CHINESE)); assertEquals("China Unicom", //$NON-NLS-1$ phoneNumberHandlerBase.getCarrierNameForNumber(CN_NUM_1, REGCODE_CN, Locale.UK)); assertEquals("China Mobile", //$NON-NLS-1$ phoneNumberHandlerBase.getCarrierNameForNumber(CN_NUM_2, REGCODE_CN, Locale.UK)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getCarrierNameForNumber(FR_NUM_3, REGCODE_FR, Locale.UK)); assertEquals("Bouygues", phoneNumberHandlerBase.getCarrierNameForNumber(FR_NUM_5, REGCODE_FR, Locale.UK)); //$NON-NLS-1$ assertEquals("Bouygues", //$NON-NLS-1$ phoneNumberHandlerBase.getCarrierNameForNumber(FR_NUM_5, REGCODE_FR, Locale.FRENCH)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getCarrierNameForNumber(US_NUM_1, REGCODE_US, Locale.UK)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getCarrierNameForNumber(DE_NUM_1, REGCODE_DE, Locale.UK)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getCarrierNameForNumber(DE_NUM_1, REGCODE_DE, Locale.GERMANY)); }
From source file:mitm.common.security.certificate.GenerateTestCertificates.java
private void generateCertificateCriticalExtendedKeyUsage() throws Exception { X509CertificateBuilder certificateBuilder = securityFactory.createX509CertificateBuilder(); String encodedPrivateKey = "30820276020100300d06092a864886f70d0101010500048202603082025c" + "0201000281810096990cdd93c7bd2ca4d406285833cd356cc668f2571338" + "46fb4dfc885f275bdfb9bf45d539f89e826e442c0a750206a33d40600711" + "09ba96eb400710edf90590604e13ff7b624001b4b75c3fd388d18bcd71b4" + "c3e4a06c08da3fed5365db5d08cfb10321235da904886ea0329dbf041fa1" + "890f97d2b53a366f643dd344cc2e69020301000102818050ee10d6e67ad9" + "73ab6471a6aeb7afd8bd0ae70d0cb43c7310cbf9210419afaacc3438fffc" + "765a2077c754ef8dafb807737c2bdec04e3d22ab6bae206ff27a05284a96" + "015d5437739ffdb6801f537b7b7406e6088a56324105bce1fcfc86bc8a29" + "e9adb0ae4152d23f695bfe585557d73da61bf7eb7c1bbdc164afed60e54e" + "bd024100ca4e8e4e7e905e4b273d1381f4323ce673d5d33ce5a75f46d719" + "8c4ea1bcc13b621f314fa6166cc6193ff912814c54a717b93804b258ec44" + "d0a212d371078cdf024100be9133919b1093a3d8c7afa1ff70ab769076c9" + "aeb5c548cdc9aef63812a57eccf77f0def9c979cfaf117d8ffb454f823de" + "245a1b90da34adaf57b8a561fde5b702407d8dcd51b7c89f4ca2f88bbfce" + "2ed38eee7ad8d3656fbf78b68c1b80bd6de8ba9305ead394af3c28a1890b" + "6a49a676af10d1198c08a7995287ecde242d74d31f024032a09ac5ad1f8b" + "49b536dfc736f8b4e4cbde7318523c366a4d9188e23eb9eee4ff3fa6f128" + "75f3038bf79cf3d9f1d4f69a76a7e5b8e6efa5d0f68a1c8ddb0923024100" + "b44f03887aa2d95203f3dee44298b12b90c163bffebdc077551208c53987" + "11e35c60f8d6348f7fd51f7a384bb397ead4957e37b0440addecc19f9fac" + "b129564b"; String encodedPublicKey = "30819f300d06092a864886f70d010101050003818d003081890281810096" + "990cdd93c7bd2ca4d406285833cd356cc668f257133846fb4dfc885f275b" + "dfb9bf45d539f89e826e442c0a750206a33d4060071109ba96eb400710ed" + "f90590604e13ff7b624001b4b75c3fd388d18bcd71b4c3e4a06c08da3fed" + "5365db5d08cfb10321235da904886ea0329dbf041fa1890f97d2b53a366f" + "643dd344cc2e690203010001"; PrivateKey privateKey = decodePrivateKey(encodedPrivateKey); PublicKey publicKey = decodePublicKey(encodedPublicKey); X500PrincipalBuilder subjectBuilder = new X500PrincipalBuilder(); String email = "test@example.com"; subjectBuilder.setCommonName("Valid certificate"); subjectBuilder.setEmail(email);/*ww w . j av a 2 s.co m*/ subjectBuilder.setCountryCode("NL"); subjectBuilder.setLocality("Amsterdam"); subjectBuilder.setState("NH"); AltNamesBuilder altNamesBuider = new AltNamesBuilder(); altNamesBuider.setRFC822Names(email); X500Principal subject = subjectBuilder.buildPrincipal(); GeneralNames altNames = altNamesBuider.buildAltNames(); // use TreeSet because we want a deterministic certificate (ie. hash should not change) Set<KeyUsageType> keyUsage = new TreeSet<KeyUsageType>(); keyUsage.add(KeyUsageType.DIGITALSIGNATURE); keyUsage.add(KeyUsageType.KEYENCIPHERMENT); keyUsage.add(KeyUsageType.NONREPUDIATION); Set<ExtendedKeyUsageType> extendedKeyUsage = new TreeSet<ExtendedKeyUsageType>(); extendedKeyUsage.add(ExtendedKeyUsageType.CLIENTAUTH); extendedKeyUsage.add(ExtendedKeyUsageType.EMAILPROTECTION); BigInteger serialNumber = new BigInteger("116a448f117ff69fe4f2d4d38f689d7", 16); Date now = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM, Locale.UK) .parse("21-Nov-2007 10:38:35"); certificateBuilder.setSubject(subject); certificateBuilder.setAltNames(altNames, true); certificateBuilder.setKeyUsage(keyUsage, true); certificateBuilder.setExtendedKeyUsage(extendedKeyUsage, true /* critical */); certificateBuilder.setNotBefore(DateUtils.addDays(now, -20)); certificateBuilder.setNotAfter(DateUtils.addYears(now, 20)); certificateBuilder.setPublicKey(publicKey); certificateBuilder.setSerialNumber(serialNumber); certificateBuilder.setSignatureAlgorithm("SHA1WithRSAEncryption"); certificateBuilder.addSubjectKeyIdentifier(true); X509Certificate certificate = certificateBuilder.generateCertificate(caPrivateKey, caCertificate); assertNotNull(certificate); certificates.add(certificate); Certificate[] chain = new Certificate[] { certificate, caCertificate, rootCertificate }; keyStore.setKeyEntry("CriticalEKU", privateKey, null, chain); }
From source file:org.talend.dataquality.standardization.phone.PhoneNumberHandlerBaseTest.java
@Test public void testgetGeocoderDescriptionForNumber() { assertEquals("", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(CN_NUM_3, REGCODE_CN, Locale.SIMPLIFIED_CHINESE)); assertEquals("Beijing", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(CN_NUM_3, REGCODE_CN, Locale.UK)); // assertEquals("??", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(CN_NUM_4, REGCODE_CN, Locale.SIMPLIFIED_CHINESE)); assertEquals("Jiujiang, Jiangxi", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(CN_NUM_4, REGCODE_CN, Locale.UK)); assertEquals("France", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(FR_NUM_1, REGCODE_FR, Locale.FRANCE)); assertEquals("Paris", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(FR_NUM_2, REGCODE_FR, Locale.FRANCE)); assertEquals(StringUtils.EMPTY,/*from www . j a va2 s . c o m*/ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(FR_NUM_3, REGCODE_FR, Locale.FRANCE)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getGeocoderDescriptionForNumber(FR_NUM_4, REGCODE_FR, Locale.FRANCE)); assertEquals("France", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(FR_NUM_5, REGCODE_FR, Locale.FRANCE)); assertEquals("Corvallis, OR", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_1, REGCODE_US, Locale.US)); assertEquals("Corvallis, OR", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_2, REGCODE_US, Locale.US)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_3, REGCODE_US, Locale.US)); assertEquals("Corvallis, OR", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_4, REGCODE_US, Locale.US)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_5, REGCODE_US, Locale.US)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_6, REGCODE_US, Locale.US)); assertEquals("Pennsylvania", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(US_NUM_7, REGCODE_US, Locale.US)); assertEquals("Mnchen", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(DE_NUM_1, REGCODE_DE, Locale.GERMANY)); assertEquals("Munich", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(DE_NUM_1, REGCODE_DE, Locale.ENGLISH)); assertEquals(StringUtils.EMPTY, phoneNumberHandlerBase.getGeocoderDescriptionForNumber(DE_NUM_2, REGCODE_DE, Locale.GERMANY)); assertEquals("Mnchen", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(DE_NUM_3, REGCODE_DE, Locale.GERMANY)); assertEquals("Nubach Pfalz", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(DE_NUM_4, REGCODE_DE, Locale.GERMANY)); assertEquals("Nussbach Pfalz", //$NON-NLS-1$ phoneNumberHandlerBase.getGeocoderDescriptionForNumber(DE_NUM_4, REGCODE_DE, Locale.ENGLISH)); }
From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java
public void setUp() throws Exception { dialect = (Dialect) ctx.getBean("dialect"); nodeService = (NodeService) ctx.getBean("dbNodeService"); dictionaryService = (DictionaryService) ctx.getBean("dictionaryService"); dictionaryDAO = (DictionaryDAO) ctx.getBean("dictionaryDAO"); luceneFTS = (FullTextSearchIndexer) ctx.getBean("LuceneFullTextSearchIndexer"); contentService = (ContentService) ctx.getBean("contentService"); queryRegisterComponent = (QueryRegisterComponent) ctx.getBean("queryRegisterComponent"); namespacePrefixResolver = (DictionaryNamespaceComponent) ctx.getBean("namespaceService"); transformerDebug = (TransformerDebug) ctx.getBean("transformerDebug"); indexerAndSearcher = (IndexerAndSearcher) ctx.getBean("admLuceneIndexerAndSearcherFactory"); luceneConfig = (LuceneConfig) ctx.getBean("admLuceneIndexerAndSearcherFactory"); ((LuceneConfig) indexerAndSearcher).setMaxAtomicTransformationTime(1000000); transactionService = (TransactionService) ctx.getBean("transactionComponent"); retryingTransactionHelper = (RetryingTransactionHelper) ctx.getBean("retryingTransactionHelper"); tenantService = (TenantService) ctx.getBean("tenantService"); queryEngine = (QueryEngine) ctx.getBean("adm.luceneQueryEngineImpl"); nodeBulkLoader = (NodeBulkLoader) ctx.getBean("nodeDAO"); serviceRegistry = (ServiceRegistry) ctx.getBean(ServiceRegistry.SERVICE_REGISTRY); namespaceDao = (NamespaceDAO) ctx.getBean("namespaceDAO"); I18NUtil.setLocale(Locale.UK); this.authenticationComponent = (AuthenticationComponent) ctx.getBean("authenticationComponent"); queryRegisterComponent.loadQueryCollection("testQueryRegister.xml"); assertEquals(true, ctx.isSingleton("LuceneFullTextSearchIndexer")); testTX = transactionService.getUserTransaction(); testTX.begin();// w w w . j ava2 s . c o m this.authenticationComponent.setSystemUserAsCurrentUser(); // load in the test model ClassLoader cl = BaseNodeServiceTest.class.getClassLoader(); InputStream modelStream = cl .getResourceAsStream("org/alfresco/repo/search/impl/lucene/LuceneTest_model.xml"); assertNotNull(modelStream); model = M2Model.createModel(modelStream); dictionaryDAO.registerListener(this); dictionaryDAO.reset(); assertNotNull(dictionaryDAO.getClass(testSuperType)); StoreRef storeRef = nodeService.createStore(StoreRef.PROTOCOL_WORKSPACE, "Test_" + System.currentTimeMillis()); rootNodeRef = nodeService.getRootNode(storeRef); n1 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}one"), testSuperType, getOrderProperties()).getChildRef(); nodeService.setProperty(n1, QName.createQName("{namespace}property-1"), "ValueOne"); n2 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}two"), testSuperType, getOrderProperties()).getChildRef(); nodeService.setProperty(n2, QName.createQName("{namespace}property-1"), "valueone"); nodeService.setProperty(n2, QName.createQName("{namespace}property-2"), "valuetwo"); n3 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}three"), testSuperType, getOrderProperties()).getChildRef(); ObjectOutputStream oos; try { ByteArrayOutputStream baos = new ByteArrayOutputStream(); oos = new ObjectOutputStream(baos); oos.writeObject(n3); oos.close(); ObjectInputStream ois = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); Object o = ois.readObject(); ois.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } Map<QName, Serializable> testProperties = new HashMap<QName, Serializable>(); testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"), "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYONE"); testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-unstored-tokenised-atomic"), "TEXT THAT IS INDEXED STORED AND TOKENISED ATOMICALLY KEYUNSTORED"); testProperties.put(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-nonatomic"), "TEXT THAT IS INDEXED STORED AND TOKENISED BUT NOT ATOMICALLY KEYTWO"); testProperties.put(QName.createQName(TEST_NAMESPACE, "int-ista"), Integer.valueOf(1)); testProperties.put(QName.createQName(TEST_NAMESPACE, "long-ista"), Long.valueOf(2)); testProperties.put(QName.createQName(TEST_NAMESPACE, "float-ista"), Float.valueOf(3.4f)); testProperties.put(QName.createQName(TEST_NAMESPACE, "double-ista"), Double.valueOf(5.6)); //testDate = new Date(((new Date().getTime() - 10000))); Calendar c = new GregorianCalendar(); c.setTime(new Date(((new Date().getTime() - 10000)))); //c.add(Calendar.MINUTE, -1); //c.set(Calendar.MINUTE, 0); //c.set(Calendar.MILLISECOND, 999); //c.set(Calendar.SECOND, 1); //c.set(Calendar.MILLISECOND, 0); //c.set(Calendar.SECOND, 0); //c.set(Calendar.MINUTE, 0); //c.set(Calendar.HOUR_OF_DAY, 0); // c.set(Calendar.YEAR, 2000); // c.set(Calendar.MONTH, 12); // c.set(Calendar.DAY_OF_MONTH, 31); // c.set(Calendar.HOUR_OF_DAY, 23); // c.set(Calendar.MINUTE, 59); // c.set(Calendar.SECOND, 59); // c.set(Calendar.MILLISECOND, 999); testDate = c.getTime(); testProperties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate); testProperties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate); testProperties.put(QName.createQName(TEST_NAMESPACE, "boolean-ista"), Boolean.valueOf(true)); testProperties.put(QName.createQName(TEST_NAMESPACE, "qname-ista"), QName.createQName("{wibble}wobble")); testProperties.put(QName.createQName(TEST_NAMESPACE, "category-ista"), new NodeRef(storeRef, "CategoryId")); testProperties.put(QName.createQName(TEST_NAMESPACE, "noderef-ista"), n1); testProperties.put(QName.createQName(TEST_NAMESPACE, "path-ista"), nodeService.getPath(n3)); testProperties.put(QName.createQName(TEST_NAMESPACE, "locale-ista"), Locale.UK); testProperties.put(QName.createQName(TEST_NAMESPACE, "period-ista"), new Period("period|12")); testProperties.put(QName.createQName(TEST_NAMESPACE, "null"), null); testProperties.put(QName.createQName(TEST_NAMESPACE, "list"), new ArrayList<Object>()); MLText mlText = new MLText(); mlText.addValue(Locale.ENGLISH, "banana"); mlText.addValue(Locale.FRENCH, "banane"); mlText.addValue(Locale.CHINESE, ""); mlText.addValue(new Locale("nl"), "banaan"); mlText.addValue(Locale.GERMAN, "banane"); mlText.addValue(new Locale("el"), ""); mlText.addValue(Locale.ITALIAN, "banana"); mlText.addValue(new Locale("ja"), "?"); mlText.addValue(new Locale("ko"), ""); mlText.addValue(new Locale("pt"), "banana"); mlText.addValue(new Locale("ru"), ""); mlText.addValue(new Locale("es"), "pltano"); testProperties.put(QName.createQName(TEST_NAMESPACE, "ml"), mlText); // Any multivalued ArrayList<Serializable> anyValues = new ArrayList<Serializable>(); anyValues.add(Integer.valueOf(100)); anyValues.add("anyValueAsString"); anyValues.add(new UnknownDataType()); testProperties.put(QName.createQName(TEST_NAMESPACE, "any-many-ista"), anyValues); // Content multivalued // - note only one the first value is used from the collection // - andit has to go in type d:any as d:content is not allowed to be multivalued ArrayList<Serializable> contentValues = new ArrayList<Serializable>(); contentValues.add(new ContentData(null, "text/plain", 0L, "UTF-16", Locale.UK)); testProperties.put(QName.createQName(TEST_NAMESPACE, "content-many-ista"), contentValues); // MLText multivalued MLText mlText1 = new MLText(); mlText1.addValue(Locale.ENGLISH, "cabbage"); mlText1.addValue(Locale.FRENCH, "chou"); MLText mlText2 = new MLText(); mlText2.addValue(Locale.ENGLISH, "lemur"); mlText2.addValue(new Locale("ru"), ""); ArrayList<Serializable> mlValues = new ArrayList<Serializable>(); mlValues.add(mlText1); mlValues.add(mlText2); testProperties.put(QName.createQName(TEST_NAMESPACE, "mltext-many-ista"), mlValues); // null in multi valued ArrayList<Object> testList = new ArrayList<Object>(); testList.add(null); testProperties.put(QName.createQName(TEST_NAMESPACE, "nullist"), testList); ArrayList<Object> testList2 = new ArrayList<Object>(); testList2.add("woof"); testList2.add(null); n4 = nodeService.createNode(rootNodeRef, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}four"), testType, testProperties).getChildRef(); ContentWriter multiWriter = contentService.getWriter(n4, QName.createQName(TEST_NAMESPACE, "content-many-ista"), true); multiWriter.setEncoding("UTF-16"); multiWriter.setMimetype("text/plain"); multiWriter.putContent("multicontent"); nodeService.getProperties(n1); nodeService.getProperties(n2); nodeService.getProperties(n3); nodeService.getProperties(n4); n5 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}five"), testSuperType, getOrderProperties()).getChildRef(); n6 = nodeService.createNode(n1, ASSOC_TYPE_QNAME, QName.createQName("{namespace}six"), testSuperType, getOrderProperties()).getChildRef(); n7 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}seven"), testSuperType, getOrderProperties()).getChildRef(); n8 = nodeService.createNode(n2, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-2"), testSuperType, getOrderProperties()).getChildRef(); n9 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}nine"), testSuperType, getOrderProperties()).getChildRef(); n10 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}ten"), testSuperType, getOrderProperties()).getChildRef(); n11 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eleven"), testSuperType, getOrderProperties()).getChildRef(); n12 = nodeService.createNode(n5, ASSOC_TYPE_QNAME, QName.createQName("{namespace}twelve"), testSuperType, getOrderProperties()).getChildRef(); n13 = nodeService.createNode(n12, ASSOC_TYPE_QNAME, QName.createQName("{namespace}thirteen"), testSuperType, getOrderProperties()).getChildRef(); Map<QName, Serializable> properties = new HashMap<QName, Serializable>(); MLText desc1 = new MLText(); desc1.addValue(Locale.ENGLISH, "Alfresco tutorial"); desc1.addValue(Locale.US, "Alfresco tutorial"); Date explicitCreatedDate = new Date(); Thread.sleep(2000); properties.put(ContentModel.PROP_CONTENT, new ContentData(null, "text/plain", 0L, "UTF-8", Locale.UK)); properties.put(ContentModel.PROP_DESCRIPTION, desc1); properties.put(ContentModel.PROP_CREATED, explicitCreatedDate); //Calendar c = new GregorianCalendar(); //c.setTime(new Date()); //c.set(Calendar.MILLISECOND, 0); //c.set(Calendar.SECOND, 0); //c.set(Calendar.MINUTE, 0); //c.set(Calendar.HOUR_OF_DAY, 0); //testDate = c.getTime(); //properties.put(QName.createQName(TEST_NAMESPACE, "date-ista"), testDate); //properties.put(QName.createQName(TEST_NAMESPACE, "datetime-ista"), testDate); // note: cm:content - hence auditable aspect will be applied with any missing mandatory properties (cm:modified, cm:creator, cm:modifier) n14 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fourteen"), ContentModel.TYPE_CONTENT, properties).getChildRef(); // nodeService.addAspect(n14, DictionaryBootstrap.ASPECT_QNAME_CONTENT, // properties); assertEquals(explicitCreatedDate, nodeService.getProperty(n14, ContentModel.PROP_CREATED)); // note: cm:thumbnail - hence auditable aspect will be applied with mandatory properties (cm:created, cm:modified, cm:creator, cm:modifier) n15 = nodeService.createNode(n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}fifteen"), ContentModel.TYPE_THUMBNAIL, getOrderProperties()).getChildRef(); nodeService.setProperty(n15, ContentModel.PROP_CONTENT, new ContentData(null, "text/richtext", 0L, "UTF-8", Locale.FRENCH)); ContentWriter writer = contentService.getWriter(n14, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); // InputStream is = // this.getClass().getClassLoader().getResourceAsStream("test.doc"); // writer.putContent(is); writer.putContent( "The quick brown fox jumped over the lazy dog and ate the Alfresco Tutorial, in pdf format, along with the following stop words; a an and are" + " as at be but by for if in into is it no not of on or such that the their then there these they this to was will with: " + " and random charcters \u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF"); // System.out.println("Size is " + writer.getSize()); writer = contentService.getWriter(n15, ContentModel.PROP_CONTENT, true); writer.setEncoding("UTF-8"); // InputStream is = // this.getClass().getClassLoader().getResourceAsStream("test.doc"); // writer.putContent(is); writer.putContent(" "); nodeService.addChild(rootNodeRef, n8, ContentModel.ASSOC_CHILDREN, QName.createQName("{namespace}eight-0")); nodeService.addChild(n1, n8, ASSOC_TYPE_QNAME, QName.createQName("{namespace}eight-1")); nodeService.addChild(n2, n13, ASSOC_TYPE_QNAME, QName.createQName("{namespace}link")); nodeService.addChild(n1, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n2, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n5, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n6, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n12, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); nodeService.addChild(n13, n14, ASSOC_TYPE_QNAME, QName.createQName("{namespace}common")); documentOrder = new NodeRef[] { rootNodeRef, n4, n5, n6, n7, n8, n9, n10, n11, n12, n13, n14, n15, n3, n1, n2 }; }
From source file:org.openmrs.module.sync.SyncConceptTest.java
License:asdf
@Test @NotTransactional/* w w w .j a v a 2s. co m*/ public void shouldUpdateConceptWordsForNumericConcepts() throws Exception { runSyncTest(new SyncTestHelper() { ConceptService cs = Context.getConceptService(); public void runOnChild() { Concept wt = cs.getConceptByName("WEIGHT"); wt.addName(new ConceptName("ASDF", Locale.UK)); cs.saveConcept(wt); } public void runOnParent() { Concept wt = cs.getConceptByName("WEIGHT"); List<ConceptWord> words = cs.getConceptWords("ASDF", Locale.UK); boolean foundConcept = false; for (ConceptWord word : words) { if (word.getConcept().equals(wt)) { foundConcept = true; } } assertTrue(foundConcept); } }); }
From source file:com.spoiledmilk.ibikecph.search.SearchAutocompleteActivity.java
private void spawnSearchThreads(final Location loc, final String searchText, final Address addr, final String tag) { if (lastAddress != null && lastAddress.equals(addr) && adapter != null && adapter.getCount() != 0) { return;//w ww . jav a 2s . c o m } else { lastAddress = addr; } if (!Util.isNetworkConnected(this)) { Util.launchNoConnectionDialog(this); progressBar.setVisibility(View.INVISIBLE); } else { // fetch the Kortforsyningen autocomplete kmsThread = new Thread(new Runnable() { @Override public void run() { // final List<JsonNode> kortforsyningenList = new ArrayList<JsonNode>(); final ArrayList<SearchListItem> data = new ArrayList<SearchListItem>(); if (!(addr.street == null || addr.street.trim().equals(""))) { List<JsonNode> list = HTTPAutocompleteHandler.getKortforsyningenAutocomplete(loc, addr); int count = 0; if (list != null) { for (JsonNode node : list) { if (count == 10) { break; } KortforData kd = new KortforData(node); if (kd.getCity() != null && addr.city != null && kd.getCity().toLowerCase(Locale.US).contains(addr.city)) { LOG.d("kd = " + kd); } if (addr.zip != null && !addr.zip.equals("") && kd.getZip() != null) { if (!addr.zip.trim().toLowerCase(Locale.UK) .equals(kd.getZip().toLowerCase(Locale.UK))) { continue; } } LOG.d("kd = " + kd); if (kd.getCity() != null && addr.city != null && kd.getCity().toLowerCase(Locale.US).contains(addr.city) && kd.getCity().contains("Aarhus")) { LOG.d("kd.city = " + kd.getCity() + " addr city = " + addr.city); } if (addr.city != null && !addr.city.equals("") && !addr.city.equals(addr.street) && kd.getCity() != null) { if (!(addr.city.trim().toLowerCase(Locale.UK) .contains(kd.getCity().toLowerCase(Locale.UK)) || kd.getCity().trim().toLowerCase(Locale.UK) .contains(addr.city.toLowerCase(Locale.UK)))) { continue; } } LOG.d("adding a kd to the list " + kd); data.add(kd); count++; } } } if (!addr.isAddress()) { List<JsonNode> places = HTTPAutocompleteHandler.getKortforsyningenPlaces(loc, addr); if (places != null) { int count = 0; if (places != null) { LOG.d("places count = " + places.size() + " data = " + places.toString()); for (JsonNode node : places) { if (count == 10) { break; } KortforData kd = new KortforData(node); if (addr.zip != null && !addr.zip.equals("") && kd.getZip() != null) { if (!addr.zip.trim().toLowerCase(Locale.UK) .equals(kd.getZip().toLowerCase(Locale.UK))) { continue; } } if (addr.city != null && !addr.city.equals("") && !addr.city.equals(addr.street) && kd.getCity() != null) { if (!(addr.city.trim().toLowerCase(Locale.UK) .contains(kd.getCity().toLowerCase(Locale.UK)) || kd.getCity().trim().toLowerCase(Locale.UK) .contains(addr.city.toLowerCase(Locale.UK)))) { continue; } } data.add(kd); count++; } } } } isOirestFetched = true; runOnUiThread(new Runnable() { public void run() { updateListData(data, tag, addr); } }); } }); kmsThread.start(); if (textSrch.getText().toString().length() >= 3 && addr.isFoursquare()) { // fetch the Foursquare autocomplete foursquareThread = new Thread(new Runnable() { @Override public void run() { List<JsonNode> list = HTTPAutocompleteHandler.getFoursquareAutocomplete(addr, SearchAutocompleteActivity.this, loc); final ArrayList<SearchListItem> data = new ArrayList<SearchListItem>(); if (list != null) { int count = 0; for (JsonNode node : list) { if (count == 3) { break; } JsonNode location = node.path("location"); if (location.has("lat") && location.has("lng") && location.get("lat").asDouble() != 0 && location.get("lng").asDouble() != 0) { String country = location.has("country") ? location.get("country").asText() : ""; if (country.contains("Denmark") || country.contains("Dansk") || country.contains("Danmark")) { FoursquareData fd = new FoursquareData(node); fd.setDistance(loc.distanceTo( Util.locationFromCoordinates(fd.getLatitude(), fd.getLongitude()))); data.add(fd); count++; } } } } isFoursquareFetched = true; runOnUiThread(new Runnable() { public void run() { updateListData(data, tag, addr); } }); } }); foursquareThread.start(); } else { isFoursquareFetched = true; } } }