List of usage examples for java.util Locale GERMAN
Locale GERMAN
To view the source code for java.util Locale GERMAN.
Click Source Link
From source file:com.zoffcc.applications.zanavi.Navit.java
protected void onActivityResult(int requestCode, int resultCode, Intent data) { Log.e("Navit", "onActivityResult"); switch (requestCode) { case Navit.ZANaviIntro_id: try {//w w w .jav a 2 s . c o m PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean(PREF_KEY_FIRST_START, false) .commit(); } catch (Exception e) { e.printStackTrace(); } case Navit.NavitGPXConvChooser_id: try { Log.e("Navit", "onActivityResult 001"); if (resultCode == AppCompatActivity.RESULT_OK) { String in_ = data.getStringExtra(FileDialog.RESULT_PATH); convert_gpx_file_real(in_); } } catch (Exception e77) { e77.printStackTrace(); } break; case NavitReplayFileConvChooser_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { final String in_ = data.getStringExtra(FileDialog.RESULT_PATH); final Thread replay_gpx_file_001 = new Thread() { @Override public void run() { try { Thread.sleep(2000); // wait 2 seconds before we start String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN) .format(new Date()); ZANaviDebugReceiver.DR_replay_gps_file(in_, date); } catch (Exception e) { } } }; replay_gpx_file_001.start(); } } catch (Exception e77) { e77.printStackTrace(); } break; case Navit.NavitDeleteSecSelectMap_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { if (!data.getStringExtra("selected_id") .equalsIgnoreCase(NavitDeleteSelectMapActivity.CANCELED_ID)) { System.out.println("Global_Location_update_not_allowed = 1"); Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now! // remove all sdcard maps Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 19); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); try { Thread.sleep(100); } catch (InterruptedException e) { } Log.d("Navit", "delete map id=" + Integer.parseInt(data.getStringExtra("selected_id"))); String map_full_line = NavitMapDownloader.OSM_MAP_NAME_ondisk_ORIG_LIST[Integer .parseInt(data.getStringExtra("selected_id"))]; Log.d("Navit", "delete map full line=" + map_full_line); String del_map_name = MAP_FILENAME_PATH + map_full_line.split(":", 2)[0]; System.out.println("del map file :" + del_map_name); // remove from cat file NavitMapDownloader.remove_from_cat_file(map_full_line); // remove from disk File del_map_name_file = new File(del_map_name); del_map_name_file.delete(); for (int jkl = 1; jkl < 51; jkl++) { File del_map_name_fileSplit = new File(del_map_name + "." + String.valueOf(jkl)); del_map_name_fileSplit.delete(); } // also remove index file File del_map_name_file_idx = new File(del_map_name + ".idx"); del_map_name_file_idx.delete(); // remove also any MD5 files for this map that may be on disk try { String tmp = map_full_line.split(":", 2)[1]; if (!tmp.equals(NavitMapDownloader.MAP_URL_NAME_UNKNOWN)) { tmp = tmp.replace("*", ""); tmp = tmp.replace("/", ""); tmp = tmp.replace("\\", ""); tmp = tmp.replace(" ", ""); tmp = tmp.replace(">", ""); tmp = tmp.replace("<", ""); System.out .println("removing md5 file:" + Navit.MAPMD5_FILENAME_PATH + tmp + ".md5"); File md5_final_filename = new File(Navit.MAPMD5_FILENAME_PATH + tmp + ".md5"); md5_final_filename.delete(); } } catch (Exception e) { e.printStackTrace(); } // remove map, and zoom out // ***** onStop(); // ***** onCreate(getIntent().getExtras()); try { Thread.sleep(100); } catch (InterruptedException e) { } // add all sdcard maps msg = new Message(); b = new Bundle(); b.putInt("Callback", 20); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); final Thread zoom_to_route_004 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_004.start(); System.out.println("Global_Location_update_not_allowed = 0"); Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now! } } } catch (Exception e) { Log.d("Navit", "error on onActivityResult 3"); e.printStackTrace(); } break; case Navit.NavitDownloaderPriSelectMap_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { try { // Log.d("Navit", "PRI id=" + Integer.parseInt(data.getStringExtra("selected_id"))); // set map id to download Navit.download_map_id = NavitMapDownloader.OSM_MAP_NAME_ORIG_ID_LIST[Integer .parseInt(data.getStringExtra("selected_id"))]; // show the map download progressbar, and download the map if (Navit.download_map_id > -1) { // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- // showDialog(Navit.MAPDOWNLOAD_PRI_DIALOG); // old method in app // new method in service Message msg = progress_handler.obtainMessage(); // Bundle b = new Bundle(); msg.what = 22; progress_handler.sendMessage(msg); // show license for OSM maps //. TRANSLATORS: please only translate the first word "Map data" and leave the other words in english Toast.makeText(getApplicationContext(), "Map data (c) OpenStreetMap contributors", Toast.LENGTH_SHORT).show(); // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- // --------- start a map download (highest level) --------- } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } } else { // user pressed back key } } catch (Exception e) { Log.d("Navit", "error on onActivityResult"); e.printStackTrace(); } break; case Navit.NavitDownloaderSecSelectMap_id: // unused!!! unused!!! unused!!! unused!!! unused!!! break; case ZANaviVoiceInput_id: if (resultCode == AppCompatActivity.RESULT_OK) { try { String addr = data.getStringExtra("address_string"); double lat = data.getDoubleExtra("lat", 0); double lon = data.getDoubleExtra("lon", 0); String hn = ""; // save last address entry string p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); Boolean partial_match = true; Navit.use_index_search = false; Navit_last_address_partial_match = partial_match; Navit_last_address_search_string = addr; Navit_last_address_hn_string = hn; Navit_last_address_full_file_search = false; // clear results Navit.NavitAddressResultList_foundItems.clear(); Navit.Navit_Address_Result_double_index.clear(); Navit.NavitSearchresultBarIndex = -1; Navit.NavitSearchresultBar_title = ""; Navit.NavitSearchresultBar_text = ""; Navit.search_results_towns = 0; Navit.search_results_streets = 0; Navit.search_results_streets_hn = 0; Navit.search_results_poi = 0; if (addr.equals("")) { // empty search string entered Toast.makeText(getApplicationContext(), Navit.get_text("No search string"), Toast.LENGTH_LONG).show(); //TRANS } else { System.out.println("Global_Location_update_not_allowed = 1"); Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now! // --> this still does the search // google_online_search_and_set_destination(addr); result_set_destination(lat, lon, addr); System.out.println("Global_Location_update_not_allowed = 0"); Navit.Global_Location_update_not_allowed = 0; // DO allow location updates now! } } catch (Exception e) { } } break; case NavitAddressSearch_id_online: case NavitAddressSearch_id_offline: Log.e("Navit", "NavitAddressSearch_id_:001"); try { if (resultCode == AppCompatActivity.RESULT_OK) { try { String addr = data.getStringExtra("address_string"); String hn = ""; try { // only from offline mask! hn = data.getStringExtra("hn_string"); } catch (Exception e) { hn = ""; } // save last address entry string p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); Boolean partial_match = false; try { // only from offline mask! partial_match = data.getStringExtra("partial_match").equals("1"); } catch (Exception e) { } Message msg2 = new Message(); Bundle b2 = new Bundle(); b2.putInt("Callback", 44); msg2.setData(b2); NavitGraphics.callback_handler.sendMessage(msg2); if (requestCode == NavitAddressSearch_id_offline) { search_hide_duplicates = false; try { Boolean hide_dup = data.getStringExtra("hide_dup").equals("1"); if (hide_dup) { search_hide_duplicates = true; Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 45); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); } } catch (Exception e) { } if (Navit.CIDEBUG == 0) { Navit.use_index_search = Navit.allow_use_index_search(); } } else { Navit.use_index_search = false; } Navit_last_address_partial_match = partial_match; Navit_last_address_search_string = addr; Navit_last_address_hn_string = hn; try { // only from offline mask! Navit_last_address_full_file_search = data.getStringExtra("full_file_search") .equals("1"); } catch (Exception e) { Navit_last_address_full_file_search = false; } try { // only from offline mask! Navit_last_address_search_country_iso2_string = data .getStringExtra("address_country_iso2"); Navit_last_address_search_country_flags = data.getIntExtra("address_country_flags", 3); // System.out.println("Navit_last_address_search_country_flags=" + Navit_last_address_search_country_flags); Navit_last_address_search_country_id = data.getIntExtra("search_country_id", 1); // default=*ALL* p.PREF_search_country = Navit_last_address_search_country_id; setPrefs_search_country(); } catch (Exception e) { } // clear results Navit.NavitAddressResultList_foundItems.clear(); Navit.Navit_Address_Result_double_index.clear(); Navit.NavitSearchresultBarIndex = -1; Navit.NavitSearchresultBar_title = ""; Navit.NavitSearchresultBar_text = ""; Navit.search_results_towns = 0; Navit.search_results_streets = 0; Navit.search_results_streets_hn = 0; Navit.search_results_poi = 0; if (addr.equals("")) { // empty search string entered Toast.makeText(getApplicationContext(), Navit.get_text("No search string entered"), Toast.LENGTH_LONG).show(); //TRANS } else { System.out.println("Global_Location_update_not_allowed = 1"); Navit.Global_Location_update_not_allowed = 1; // dont allow location updates now! if (requestCode == NavitAddressSearch_id_online) { // online googlemaps search try { Log.e("Navit", "call-11: (1)num " + Navit.SEARCHRESULTS_WAIT_DIALOG); } catch (Exception e) { e.printStackTrace(); } System.out.println("dialog -- 11:003"); System.out.println("online googlemaps search"); Message msg = progress_handler.obtainMessage(); Bundle b = new Bundle(); msg.what = 11; b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG); msg.setData(b); progress_handler.sendMessage(msg); } else if (requestCode == NavitAddressSearch_id_offline) { // offline binfile search if (!Navit.use_index_search) { try { Log.e("Navit", "call-11: (2)num " + Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE); } catch (Exception e) { e.printStackTrace(); } // show dialog, and start search for the results // make it indirect, to give our activity a chance to startup // (remember we come straight from another activity and ours is still paused!) System.out.println("dialog -- 11:004"); Message msg = progress_handler.obtainMessage(); Bundle b = new Bundle(); msg.what = 11; b.putInt("dialog_num", Navit.SEARCHRESULTS_WAIT_DIALOG_OFFLINE); msg.setData(b); progress_handler.sendMessage(msg); } } } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } } else { // user pressed back key Log.e("Navit", "NavitAddressSearch_id_:900"); } } catch (Exception e) { Log.d("Navit", "error on onActivityResult"); e.printStackTrace(); } Log.e("Navit", "NavitAddressSearch_id_:999"); break; case Navit.NavitAddressResultList_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { try { if (data.getStringExtra("what").equals("view")) { // get the coords for the destination int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); // save last address entry string String addr = data.getStringExtra("address_string"); p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); try { Navit.follow_button_off(); } catch (Exception e2) { e2.printStackTrace(); } System.out.println("XSOM:009"); if (Navit.use_index_search) { show_geo_on_screen_with_zoom_and_delay( (float) Navit.transform_to_geo_lat( Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon( Navit.NavitAddressResultList_foundItems.get(destination_id).lon)); } else { show_geo_on_screen_with_zoom_and_delay( Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon); } } else if (data.getStringExtra("what").equals("set")) { Log.d("Navit", "adress result list id=" + Integer.parseInt(data.getStringExtra("selected_id"))); // save last address entry string String addr = data.getStringExtra("address_string"); p.PREF_StreetSearchStrings = pushToArray(p.PREF_StreetSearchStrings, addr, STREET_SEARCH_STRINGS_SAVE_COUNT); saveArray(p.PREF_StreetSearchStrings, "xxStrtSrhStrxx", STREET_SEARCH_STRINGS_SAVE_COUNT); // get the coords for the destination int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); String _addr = ""; double _lat = 0; double _lon = 0; // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon) // (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat) // ok now set target try { if (Navit.use_index_search) { _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr; _lat = Navit.transform_to_geo_lat( Navit.NavitAddressResultList_foundItems.get(destination_id).lat); _lon = Navit.transform_to_geo_lon( Navit.NavitAddressResultList_foundItems.get(destination_id).lon); //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, (float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)); } else { _addr = Navit.NavitAddressResultList_foundItems.get(destination_id).addr; _lat = Navit.NavitAddressResultList_foundItems.get(destination_id).lat; _lon = Navit.NavitAddressResultList_foundItems.get(destination_id).lon; //Navit.remember_destination(Navit.NavitAddressResultList_foundItems.get(destination_id).addr, Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon); } // save points //write_map_points(); } catch (Exception e) { e.printStackTrace(); } route_wrapper(_addr, 0, 0, false, _lat, _lon, true); final Thread zoom_to_route_005 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_005.start(); // zoom_to_route(); // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- if (p.PREF_enable_debug_write_gpx) { write_route_to_gpx_file(); } // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } // if (Navit.use_index_search) // { // show_geo_on_screen((float) Navit.transform_to_geo_lat(Navit.NavitAddressResultList_foundItems.get(destination_id).lat), (float) Navit.transform_to_geo_lon(Navit.NavitAddressResultList_foundItems.get(destination_id).lon)); // } // else // { // show_geo_on_screen(Navit.NavitAddressResultList_foundItems.get(destination_id).lat, Navit.NavitAddressResultList_foundItems.get(destination_id).lon); // } } else { // -- nothing -- } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } catch (Exception e) { } } else { // user pressed back key } } catch (Exception e) { Log.d("Navit", "error on onActivityResult"); e.printStackTrace(); } break; case NavitAddressSearch_id_gmaps: try { if (resultCode == AppCompatActivity.RESULT_OK) { } } catch (Exception e) { e.printStackTrace(); } break; case NavitAddressSearch_id_sharedest: try { if (resultCode == AppCompatActivity.RESULT_OK) { } Log.d("Navit", "sharedest: finished"); } catch (Exception e) { e.printStackTrace(); } break; case NavitGeoCoordEnter_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { // lat lon enter activitiy result try { if (data.getStringExtra("what").equals("view")) { // get the coords for the destination float lat = Float.parseFloat(data.getStringExtra("lat")); float lon = Float.parseFloat(data.getStringExtra("lon")); // Log.d("Navit", "coord picker: " + lat); // Log.d("Navit", "coord picker: " + lon); // set nice zoomlevel before we show destination // int zoom_want = Navit_SHOW_DEST_ON_MAP_ZOOMLEVEL; // // // Message msg = new Message(); // Bundle b = new Bundle(); // b.putInt("Callback", 33); // b.putString("s", Integer.toString(zoom_want)); // msg.setData(b); // try // { // N_NavitGraphics.callback_handler.sendMessage(msg); // Navit.GlobalScaleLevel = zoom_want; // } // catch (Exception e) // { // e.printStackTrace(); // } // if (PREF_save_zoomlevel) // { // setPrefs_zoomlevel(); // } // set nice zoomlevel before we show destination try { Navit.follow_button_off(); } catch (Exception e2) { e2.printStackTrace(); } show_geo_on_screen(lat, lon); } else { // get the coords for the destination float lat = Float.parseFloat(data.getStringExtra("lat")); float lon = Float.parseFloat(data.getStringExtra("lat")); String dest_name = "manual coordinates"; // ok now set target try { dest_name = NavitGraphics.CallbackGeoCalc(8, lat, lon); if ((dest_name.equals(" ")) || (dest_name == null)) { dest_name = "manual coordinates"; } // Navit.remember_destination(dest_name, lat, lon); // // save points // write_map_points(); } catch (Exception e) { e.printStackTrace(); } // // DEBUG: clear route rectangle list // NavitGraphics.route_rects.clear(); // // if (NavitGraphics.navit_route_status == 0) // { // Navit.destination_set(); // // Message msg = new Message(); // Bundle b = new Bundle(); // b.putInt("Callback", 3); // b.putString("lat", String.valueOf(lat)); // b.putString("lon", String.valueOf(lon)); // b.putString("q", dest_name); // msg.setData(b); // NavitGraphics.callback_handler.sendMessage(msg); // } // else // { // Message msg = new Message(); // Bundle b = new Bundle(); // b.putInt("Callback", 48); // b.putString("lat", String.valueOf(lat)); // b.putString("lon", String.valueOf(lon)); // b.putString("q", dest_name); // msg.setData(b); // NavitGraphics.callback_handler.sendMessage(msg); // } // route_wrapper(dest_name, 0, 0, false, lat, lon, true); final Thread zoom_to_route_006 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_006.start(); // zoom_to_route(); // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- if (p.PREF_enable_debug_write_gpx) { write_route_to_gpx_file(); } // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } // show_geo_on_screen(lat, lon); } } catch (NumberFormatException e) { Log.d("Navit", "NumberFormatException selected_id"); } catch (Exception e) { } } } catch (Exception e) { e.printStackTrace(); } break; case NavitRecentDest_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { Log.d("Navit", "recent dest id=" + Integer.parseInt(data.getStringExtra("selected_id"))); // get the coords for the destination int destination_id = Integer.parseInt(data.getStringExtra("selected_id")); if (data.getStringExtra("what").equals("view")) { try { Navit.follow_button_off(); } catch (Exception e2) { e2.printStackTrace(); } float lat = Navit.map_points.get(destination_id).lat; float lon = Navit.map_points.get(destination_id).lon; show_geo_on_screen_with_zoom_and_delay(lat, lon, 150); } else { // ok now set target String dest_name = Navit.map_points.get(destination_id).point_name; float lat = Navit.map_points.get(destination_id).lat; float lon = Navit.map_points.get(destination_id).lon; // System.out.println("XXXXXX:" + lat + " " + lon); route_wrapper(dest_name, 0, 0, false, lat, lon, true); final Thread zoom_to_route_007 = new Thread() { int wait = 1; int count = 0; int max_count = 60; @Override public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { zoom_to_route(); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; } else { Thread.sleep(400); } } catch (Exception e) { } } } }; zoom_to_route_007.start(); // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- if (p.PREF_enable_debug_write_gpx) { write_route_to_gpx_file(); } // ---------- DEBUG: write route to file ---------- // ---------- DEBUG: write route to file ---------- try { Navit.follow_button_on(); } catch (Exception e2) { e2.printStackTrace(); } } } } catch (Exception e) { e.printStackTrace(); } break; case NavitSendFeedback_id: try { if (resultCode == AppCompatActivity.RESULT_OK) { String feedback_text = data.getStringExtra("feedback_text"); String subject_d_version = ""; if (Navit_DonateVersion_Installed) { subject_d_version = subject_d_version + "D,"; } if (Navit_Largemap_DonateVersion_Installed) { subject_d_version = subject_d_version + "L,"; } try { int rl = get_reglevel(); if (rl > 0) { subject_d_version = "U" + rl + ","; } } catch (Exception e) { e.printStackTrace(); } String FD_addon = ""; if (FDBL) { FD_addon = ",FD"; } sendEmail("feedback@zanavi.cc", "ZANavi Feedback (v:" + subject_d_version + FD_addon + NavitAppVersion + " a:" + android.os.Build.VERSION.SDK + ")", feedback_text); } } catch (Exception e) { e.printStackTrace(); Toast.makeText(getApplicationContext(), Navit.get_text("there was a problem with sending feedback"), Toast.LENGTH_SHORT).show(); //TRANS } break; default: Log.e("Navit", "onActivityResult " + requestCode + " " + resultCode); try { // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ActivityResults[requestCode].onActivityResult(requestCode, resultCode, data); // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- // ---------- what is this doing ????? ---------- } catch (Exception e) { e.printStackTrace(); } break; } Log.e("Navit", "onActivityResult finished"); }
From source file:org.alfresco.repo.search.impl.lucene.ADMLuceneTest.java
private void runBaseTests() throws LuceneIndexException, IOException { ADMLuceneSearcherImpl searcher = buildSearcher(); ResultSet results;//from w w w . j a v a 2 s. c o m results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/.\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:three\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:four\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:eight-0\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:five\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:one\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:two\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:one\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:two\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:six\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:seven\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:eight-1\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:eight-2\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:eight-2\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:eight-1\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:two/namespace:eight-0\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:eight-0\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:nine\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:ten\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:eleven\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:twelve\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:thirteen\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:thirteen/namespace:fourteen\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:thirteen/namespace:common\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:five/namespace:twelve/namespace:common\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*\"", null); assertEquals(5, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/namespace:*/namespace:*\"", null); assertEquals(8, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*/namespace:*\"", null); assertEquals(6, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*/namespace:five\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/namespace:*/namespace:*/namespace:*\"", null); assertEquals(9, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*/namespace:*/namespace:*\"", null); assertEquals(6, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:*\"", null); assertEquals(4, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:*/namespace:five/namespace:*\"", null); assertEquals(5, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/namespace:*/namespace:nine\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*\"", null); assertEquals(5, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/*/*\"", null); assertEquals(8, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*\"", null); assertEquals(6, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/namespace:five\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/*/*/*\"", null); assertEquals(9, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/*/*\"", null); assertEquals(6, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/*\"", null); assertEquals(4, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/*/namespace:five/*\"", null); assertEquals(5, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/namespace:one/*/namespace:nine\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//.\"", null); assertEquals(28, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//.\"", null); assertEquals(16, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//*\"", null); assertEquals(15, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//*\"", null); assertEquals(27, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//*/.\"", null); assertEquals(15, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//*/.\"", null); assertEquals(27, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//*/./.\"", null); assertEquals(15, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//*/./.\"", null); assertEquals(27, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//./*\"", null); assertEquals(27, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//./*\"", null); assertEquals(15, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//././*/././.\"", null); assertEquals(15, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//././*/././.\"", null); assertEquals(27, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"//common\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"//common\"", null); assertEquals(7, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//common\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/one//common\"", null); assertEquals(5, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one/five//*\"", null); assertEquals(7, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/one/five//*\"", null); assertEquals(10, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one/five//.\"", null); assertEquals(8, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATHWITHREPEATS:\"/one/five//.\"", null); assertEquals(11, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//five/nine\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen/.\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen//.\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PATH:\"/one//thirteen/fourteen//.//.\"", null); assertEquals(1, results.length()); results.close(); // QNames results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "QNAME:\"nine\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PRIMARYASSOCTYPEQNAME:\"lucene-test:assoc\"", null); assertEquals(11, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASSOCTYPEQNAME:\"lucene-test:assoc\"", null); assertEquals(11, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "PRIMARYASSOCTYPEQNAME:\"sys:children\"", null); assertEquals(4, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASSOCTYPEQNAME:\"sys:children\"", null); assertEquals(5, results.length()); results.close(); // Type search tests QName qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"1\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":1", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"01\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":01", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + escapeQName(qname) + ":\"001\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@lucene-test\\:int\\-ista:\"0001\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 2]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO 2]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO A]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 1}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO 1}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO A}", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 2}", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{1 TO 2}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{1 TO A}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"2\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"02\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"002\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"0002\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 2]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO 2]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[0 TO A]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 2}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO 2}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{0 TO A}", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 3}", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{2 TO 3}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "long-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{2 TO A}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"3.4\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 4]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3 TO 4]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3 TO A]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 3.4]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO 3.4]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO A]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 3.4}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO 3.4]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[3.3 TO A]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"3.40\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"03.4\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "float-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"03.40\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"5.6\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"05.6\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"5.60\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "double-ista")) + ":\"05.60\"", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[A TO 5.7]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[5.5 TO 5.7]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[5.5 TO A]", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 5.6}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.5 TO 5.6}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.5 TO A}", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{A TO 5.7}", null); assertEquals(1, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.6 TO 5.7}", null); assertEquals(0, results.length()); results.close(); qname = QName.createQName(TEST_NAMESPACE, "double-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":{5.6 TO A}", null); assertEquals(0, results.length()); results.close(); // Dates PropertyDefinition propertyDef = dictionaryService .getProperty(QName.createQName(TEST_NAMESPACE, "datetime-ista")); DataTypeDefinition dataType = propertyDef.getDataType(); String analyserClassName = propertyDef.resolveAnalyserClassName(); boolean usesDateTimeAnalyser = analyserClassName.equals(DateTimeAnalyser.class.getCanonicalName()); Date date = new Date(); for (SimpleDateFormatAndResolution df : CachingDateFormat.getLenientFormatters()) { if (!usesDateTimeAnalyser && (df.getResolution() < Calendar.DAY_OF_MONTH)) { continue; } System.out.println("Date format: " + df.getSimpleDateFormat()); // if(usesDateTimeAnalyser && (df.getSimpleDateFormat().format(date).length() < 22)) // { // continue; // } // String sDate = df.getSimpleDateFormat().format(date); // results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "DATE-ista")) + ":\"" + sDate + "\"", null); // assertEquals(1, results.length()); // results.close(); // // results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"", null); // assertEquals(usesDateTimeAnalyser ? 0 : 1, results.length()); // results.close(); String sDate = df.getSimpleDateFormat().format(testDate); if (sDate.length() >= 9) { results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":\"" + sDate + "\"", null); assertEquals(1, results.length()); results.close(); } results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"", null); assertEquals(1, results.length()); results.close(); // short and long field ranges // note: expected 2 results = n14 (cm:content) and n15 (cm:thumbnail) sDate = df.getSimpleDateFormat().format(date); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@cm\\:CrEaTeD:[MIN TO " + sDate + "]", null); assertEquals(2, results.length()); assertTrue("n14 not in results", (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14))); assertTrue("n15 not in results", (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@cm\\:created:[MIN TO NOW]", null); assertEquals(2, results.length()); assertTrue("n14 not in results", (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14))); assertTrue("n15 not in results", (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@cm\\:created:[MIN TO NOW]", null); assertEquals(2, results.length()); assertTrue("n14 not in results", (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14))); assertTrue("n15 not in results", (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15))); results.close(); sDate = df.getSimpleDateFormat().format(date); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(ContentModel.PROP_CREATED) + ":[MIN TO " + sDate + "]", null); assertEquals(2, results.length()); assertTrue("n14 not in results", (results.getNodeRef(0).equals(n14) || results.getNodeRef(1).equals(n14))); assertTrue("n15 not in results", (results.getNodeRef(0).equals(n15) || results.getNodeRef(1).equals(n15))); results.close(); // Date ranges // Test date collapses but date time does not if (sDate.length() >= 9) { sDate = df.getSimpleDateFormat().format(testDate); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[" + sDate + " TO " + sDate + "]", null); assertEquals(1, results.length()); results.close(); sDate = df.getSimpleDateFormat().format(testDate); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[MIN TO " + sDate + "]", null); assertEquals(1, results.length()); results.close(); sDate = df.getSimpleDateFormat().format(testDate); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "date-ista")) + ":[" + sDate + " TO MAX]", null); assertEquals(1, results.length()); results.close(); } if (!usesDateTimeAnalyser) { // with date time the result is indeterminate sDate = CachingDateFormat.getDateFormat().format(testDate); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate + " TO " + sDate + "]", null); assertEquals(1, results.length()); results.close(); } sDate = CachingDateFormat.getDateFormat().format(testDate); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[MIN TO " + sDate + "]", null); assertEquals(1, results.length()); results.close(); sDate = CachingDateFormat.getDateFormat().format(testDate); System.out.println("SD = " + sDate); System.out.println("D = " + date); if (!usesDateTimeAnalyser) { results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":\"" + sDate + "\"", null); //TODO: Fix date time resolution - uses 000 MS assertEquals(1, results.length()); results.close(); } if (!usesDateTimeAnalyser) { results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate + " TO MAX]", null); assertEquals(1, results.length()); results.close(); } if (usesDateTimeAnalyser) { sDate = df.getSimpleDateFormat().format(testDate); System.out.println("Test Date = " + testDate); System.out.println("Formatted = " + sDate); for (long i : new long[] { 333, 20000, 20 * 60 * 1000, 8 * 60 * 60 * 1000, 10 * 24 * 60 * 60 * 1000, 4 * 30 * 24 * 60 * 60 * 1000, 10 * 12 * 30 * 24 * 60 * 60 * 1000 }) { System.out.println("I = " + i); String startDate = df.getSimpleDateFormat().format(new Date(testDate.getTime() - i)); System.out.println("\tStart = " + startDate); String endDate = df.getSimpleDateFormat().format(new Date(testDate.getTime() + i)); System.out.println("\tEnd = " + endDate); boolean equalsStart = startDate.equals(sDate); boolean equalsEnd = endDate.equals(sDate); boolean equalsStartOrEnd = equalsStart || equalsEnd; results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + startDate + " TO " + endDate + "]", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + sDate + " TO " + endDate + "]", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":[" + startDate + " TO " + sDate + "]", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":{" + sDate + " TO " + endDate + "}", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "datetime-ista")) + ":{" + startDate + " TO " + sDate + "}", null); assertEquals(0, results.length()); results.close(); } } } results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "boolean-ista")) + ":\"true\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "qname-ista")) + ":\"{wibble}wobble\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "category-ista")) + ":\"" + DefaultTypeConverter.INSTANCE.convert(String.class, new NodeRef(rootNodeRef.getStoreRef(), "CategoryId")) + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "noderef-ista")) + ":\"" + n1 + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "path-ista")) + ":\"" + nodeService.getPath(n3) + "\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); // d:any results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "any-many-ista")) + ":\"100\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "any-many-ista"))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "any-many-ista")) + ":\"anyValueAsString\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "any-many-ista"))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "any-many-ista")) + ":\"nintc\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "any-many-ista"))); results.close(); // proximity searches results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~0", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~1", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~2", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"Tutorial Alfresco\"~3", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Alfresco Tutorial\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~0", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~1", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~2", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Tutorial Alfresco\"~3", null); assertEquals(1, results.length()); results.close(); // multi ml text QName multimlQName = QName.createQName(TEST_NAMESPACE, "mltext-many-ista"); SearchParameters sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":"); sp.addLocale(new Locale("ru")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":lemur"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":chou"); sp.addLocale(new Locale("fr")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cabbage"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cabba*"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":ca*ge"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":*bage"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cabage~"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":*b?ag?"); sp.addLocale(new Locale("en")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(multimlQName.toString()) + ":cho*"); sp.setMlAnalaysisMode(MLAnalysisMode.LOCALE_AND_ALL_CONTAINED_LOCALES); sp.addLocale(new Locale("fr")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // multivalued content in type d:any // This should not be indexed as we can not know what to do with content here. sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery( QName.createQName(TEST_NAMESPACE, "content-many-ista").toString()) + ":multicontent"); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); // locale results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":\"en_GB_\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":en_GB_", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":en_*", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":*_GB_*", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "locale-ista")) + ":*_gb_*", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); // Period results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "period-ista")) + ":\"period|12\"", null); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(QName.createQName(TEST_NAMESPACE, "path-ista"))); results.close(); // Type results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + testType.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + testType.toPrefixString(namespacePrefixResolver) + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTTYPE:\"" + testType.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTTYPE:\"" + testType.toPrefixString(namespacePrefixResolver) + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + testSuperType.toString() + "\"", null); assertEquals(13, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + testSuperType.toPrefixString(namespacePrefixResolver) + "\"", null); assertEquals(13, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + ContentModel.TYPE_CONTENT.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"cm:content\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"cm:CONTENT\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"CM:CONTENT\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"CONTENT\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"content\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + ContentModel.TYPE_THUMBNAIL.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TYPE:\"" + ContentModel.TYPE_THUMBNAIL.toString() + "\" TYPE:\"" + ContentModel.TYPE_CONTENT.toString() + "\"", null); assertEquals(2, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTTYPE:\"" + testSuperType.toString() + "\"", null); assertEquals(12, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTTYPE:\"" + testSuperType.toPrefixString(namespacePrefixResolver) + "\"", null); assertEquals(12, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASPECT:\"" + testAspect.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "ASPECT:\"" + testAspect.toPrefixString(namespacePrefixResolver) + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTASPECT:\"" + testAspect.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "EXACTASPECT:\"" + testAspect.toPrefixString(namespacePrefixResolver) + "\"", null); assertEquals(1, results.length()); results.close(); // Test for AR-384 results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fox AND TYPE:\"" + ContentModel.PROP_CONTENT.toString() + "\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fox cm\\:name:fox", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fo AND TYPE:\"" + ContentModel.PROP_CONTENT.toString() + "\"", null); assertEquals(0, results.length()); results.close(); // Test stop words are equivalent results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"the\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"and\"", null); assertEquals(0, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"over the lazy\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"over a lazy\"", null); assertEquals(1, results.length()); results.close(); // Test wildcards in text //ALF-2389 //results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic"))+":*en*", null); //assertEquals(0, results.length()); //results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*a*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*A*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":\"*a*\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":\"*A\"*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*s*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":*S*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":\"*s*\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(QName.createQName(TEST_NAMESPACE, "text-indexed-stored-tokenised-atomic")) + ":\"*S\"*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*A*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*a*\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*A*\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*a*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*Z*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*z*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*Z*\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"*z*\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:laz*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:laz~", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:la?y", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:?a?y", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*azy", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*az*", null); assertEquals(1, results.length()); results.close(); // Accents results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"\u00E0\u00EA\u00EE\u00F0\u00F1\u00F6\u00FB\u00FF\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"aeidnouy\"", null); assertEquals(1, results.length()); results.close(); // FTS test results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"fox\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":\"fox\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ".mimetype:\"text/plain\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ".locale:\"en_GB\"", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ".locale:en_*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ".locale:e*_GB", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ".size:\"298\"", null); assertEquals(1, results.length()); results.close(); QName queryQName = QName.createQName("alf:test1", namespacePrefixResolver); results = searcher.query(rootNodeRef.getStoreRef(), queryQName, null); assertEquals(1, results.length()); results.close(); // Configuration of TEXT sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":\"fox\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"fox\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"fox\""); sp.addTextAttribute("@" + ContentModel.PROP_NAME.toString()); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp.addTextAttribute("@" + ContentModel.PROP_CONTENT.toString()); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"cabbage\""); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"cab*\""); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*bage\""); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*ba*\""); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); // term sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:cabbage"); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:*cab*"); sp.addTextAttribute("@" + orderText.toString()); sp.addLocale(Locale.ENGLISH); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:*bage"); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:*ba*"); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:dabbage~0.8"); sp.addTextAttribute("@" + orderText.toString()); results = searcher.query(sp); assertEquals(13, results.length()); results.close(); // Wild cards in TEXT phrase sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfresc?\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfres??\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfre???\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfr????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alf?????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"al??????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"a???????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"a??re???\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"?lfresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"??fresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"???resco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"???res?o\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"????e?co\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"????e?c?\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"???????o\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"???re???\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfresc*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfres*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfre*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfr*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alf*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"al*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"a*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"a****\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*lfresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*fresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*resco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*esco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*sco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*co\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*o\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"****lf**sc***\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*??*lf**sc***\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alfresc*tutorial\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"alf* tut*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("TEXT:\"*co *al\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // Wild cards in ML phrases sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfresc?\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfres??\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfre???\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfr????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alf?????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"al??????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"a???????\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"a??re???\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"?lfresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"??fresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"???resco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"???res?o\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"????e?co\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"????e?c?\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"???????o\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"???re???\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfresc*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfres*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfre*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alfr*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"alf*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"al*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"a*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"a****\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*lfresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*fresco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*resco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*esco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*sco\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*co\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*o\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"****lf**sc***\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*??*lf**sc***\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Alfresc*tutorial\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"Alf* tut*\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_DESCRIPTION.toString()) + ":\"*co *al\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // ALL and its configuration sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ALL:\"fox\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ALL:\"fox\""); sp.addAllAttribute("@" + ContentModel.PROP_NAME.toString()); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp.addAllAttribute("@" + ContentModel.PROP_CONTENT.toString()); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ALL:\"5.6\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // Search by data type sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("d\\:double:\"5.6\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("d\\:content:\"fox\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // locale serach in en_US for en_UK sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("d\\:content:\"fox\""); sp.addLocale(Locale.US); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // Direct ML tests QName mlQName = QName.createQName(TEST_NAMESPACE, "ml"); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setMlAnalaysisMode(MLAnalysisMode.ALL_ONLY); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":and"); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setMlAnalaysisMode(MLAnalysisMode.ALL_ONLY); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":\"and\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setMlAnalaysisMode(MLAnalysisMode.ALL_ONLY); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); sp.addLocale(Locale.UK); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); sp.setMlAnalaysisMode(MLAnalysisMode.LOCALE_AND_ALL_CONTAINING_LOCALES); sp.addLocale(Locale.UK); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); sp.addLocale(Locale.ENGLISH); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banane"); sp.addLocale(Locale.FRENCH); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":"); sp.addLocale(Locale.CHINESE); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banaan"); sp.addLocale(new Locale("nl")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banane"); sp.addLocale(Locale.GERMAN); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":"); sp.addLocale(new Locale("el")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); sp.addLocale(Locale.ITALIAN); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":?"); sp.addLocale(new Locale("ja")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":"); sp.addLocale(new Locale("ko")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":banana"); sp.addLocale(new Locale("pt")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":"); sp.addLocale(new Locale("ru")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("@" + SearchLanguageConversion.escapeLuceneQuery(mlQName.toString()) + ":pltano"); sp.addLocale(new Locale("es")); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); // Test ISNULL/ISUNSET/ISNOTNULL sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISUNSET:\"" + QName.createQName(TEST_NAMESPACE, "null").toString() + "\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISNULL:\"" + QName.createQName(TEST_NAMESPACE, "null").toString() + "\""); results = searcher.query(sp); // assertEquals(62, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISUNSET:\"" + QName.createQName(TEST_NAMESPACE, "path-ista").toString() + "\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISNULL:\"" + QName.createQName(TEST_NAMESPACE, "path-ista").toString() + "\""); results = searcher.query(sp); // assertEquals(61, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISNOTNULL:\"" + QName.createQName(TEST_NAMESPACE, "null").toString() + "\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISNOTNULL:\"" + QName.createQName(TEST_NAMESPACE, "path-ista").toString() + "\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISUNSET:\"" + QName.createQName(TEST_NAMESPACE, "aspectProperty").toString() + "\""); results = searcher.query(sp); assertEquals(1, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISNULL:\"" + QName.createQName(TEST_NAMESPACE, "aspectProperty").toString() + "\""); results = searcher.query(sp); // assertEquals(62, results.length()); results.close(); sp = new SearchParameters(); sp.addStore(rootNodeRef.getStoreRef()); sp.setLanguage("lucene"); sp.setQuery("ISNOTNULL:\"" + QName.createQName(TEST_NAMESPACE, "aspectProperty").toString() + "\""); results = searcher.query(sp); assertEquals(0, results.length()); results.close(); // Test non field queries results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fox", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:fo*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:f*x", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:*ox", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":fox", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":fo*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":f*x", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion.escapeLuceneQuery(ContentModel.PROP_CONTENT.toString()) + ":*ox", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":fox", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":fo*", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":f*x", null); assertEquals(1, results.length()); results.close(); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "@" + SearchLanguageConversion .escapeLuceneQuery(ContentModel.PROP_CONTENT.toPrefixString(namespacePrefixResolver)) + ":*ox", null); assertEquals(1, results.length()); results.close(); // Parameters queryQName = QName.createQName("alf:test2", namespacePrefixResolver); results = searcher.query(rootNodeRef.getStoreRef(), queryQName, null); assertEquals(1, results.length()); results.close(); queryQName = QName.createQName("alf:test2", namespacePrefixResolver); QueryParameter qp = new QueryParameter(QName.createQName("alf:banana", namespacePrefixResolver), "woof"); results = searcher.query(rootNodeRef.getStoreRef(), queryQName, new QueryParameter[] { qp }); assertEquals(0, results.length()); results.close(); queryQName = QName.createQName("alf:test3", namespacePrefixResolver); qp = new QueryParameter(QName.createQName("alf:banana", namespacePrefixResolver), "/one/five//*"); results = searcher.query(rootNodeRef.getStoreRef(), queryQName, new QueryParameter[] { qp }); assertEquals(7, results.length()); results.close(); // TODO: should not have a null property type definition QueryParameterDefImpl paramDef = new QueryParameterDefImpl( QName.createQName("alf:lemur", namespacePrefixResolver), (DataTypeDefinition) null, true, "fox"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "TEXT:\"${alf:lemur}\"", new QueryParameterDefinition[] { paramDef }); assertEquals(1, results.length()); results.close(); paramDef = new QueryParameterDefImpl(QName.createQName("alf:intvalue", namespacePrefixResolver), (DataTypeDefinition) null, true, "1"); qname = QName.createQName(TEST_NAMESPACE, "int-ista"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":\"${alf:intvalue}\"", new QueryParameterDefinition[] { paramDef }); assertEquals(1, results.length()); assertNotNull(results.getRow(0).getValue(qname)); results.close(); // Open ended ranges qname = QName.createQName("{namespace}property-1"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[v TO w]", null); assertEquals(2, results.length()); results.close(); qname = QName.createQName("{namespace}property-1"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[v TO \uFFFF]", null); assertEquals(2, results.length()); results.close(); qname = QName.createQName("{namespace}property-1"); results = searcher.query(rootNodeRef.getStoreRef(), "lucene", "\\@" + escapeQName(qname) + ":[\u0000 TO w]", null); assertEquals(2, results.length()); results.close(); }
From source file:com.zoffcc.applications.zanavi.Navit.java
public static void write_route_to_gpx_file() { final Thread write_route_to_gpx_file_001 = new Thread() { int wait = 1; int count = 0; int max_count = 300; // wait 2 minutes for route to be calculated @Override// w ww . jav a 2 s . c o m public void run() { while (wait == 1) { try { if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) { Message msg = new Message(); Bundle b = new Bundle(); b.putInt("Callback", 96); String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN) .format(new Date()); String filename = Navit.NAVIT_DATA_DEBUG_DIR + "zanavi_route_" + date + ".gpx"; b.putString("s", filename); System.out.println("Debug:" + "file=" + filename); msg.setData(b); NavitGraphics.callback_handler.sendMessage(msg); Message msg7 = Navit_progress_h.obtainMessage(); Bundle b7 = new Bundle(); msg7.what = 2; // long Toast message b7.putString("text", Navit.get_text("saving route to GPX-file") + " " + filename); //TRANS msg7.setData(b7); Navit_progress_h.sendMessage(msg7); wait = 0; } else { wait = 1; } count++; if (count > max_count) { wait = 0; Message msg7 = Navit_progress_h.obtainMessage(); Bundle b7 = new Bundle(); msg7.what = 2; // long Toast message b7.putString("text", Navit.get_text("saving route to GPX-file failed")); //TRANS msg7.setData(b7); Navit_progress_h.sendMessage(msg7); } else { Thread.sleep(400); } } catch (Exception e) { } } } }; write_route_to_gpx_file_001.start(); }