diff --git a/data-discovery/src/main/java/vlkb/search/DbPSearch.java b/data-discovery/src/main/java/vlkb/search/DbPSearch.java index 47e7ec9b5e3939c56b61cf4eb537413a8597927d..a65895a07f3a807e42d0803ef2639de96d703ef4 100644 --- a/data-discovery/src/main/java/vlkb/search/DbPSearch.java +++ b/data-discovery/src/main/java/vlkb/search/DbPSearch.java @@ -75,44 +75,51 @@ public class DbPSearch } - String theQuery ="SELECT obs_publisher_did FROM obscore WHERE (" + inputRegion + " && polygon_region_galactic)"; + String theQuery; + if(coord.skySystem.equals("GALACTIC")) + { + theQuery ="SELECT obs_publisher_did FROM obscore WHERE (" + inputRegion + " && polygon_region_galactic)"; + } + else + { + theQuery ="SELECT obs_publisher_did FROM obscore WHERE (" + inputRegion + " && polygon_region)"; + } + if(vel_valid) + { + String vel_no_overlap = "((em_min > " + Double.toString(vel_up) + ") OR (em_max < " + Double.toString(vel_low) + "))"; - if(vel_valid) - { - String vel_no_overlap = "((em_min > " + Double.toString(vel_up) + ") OR (em_max < " + Double.toString(vel_low) + "))"; + theQuery += " AND ( (NOT " + vel_no_overlap + ") OR (em_min is null) OR (em_max is null))"; + /* NOTE '... OR (em_min is null)' statement causes to include 2D-continuum datasets if they overlap in sky + * It is the legacy-search behaviour - however is that useful ? + */ + } - theQuery += " AND ( (NOT " + vel_no_overlap + ") OR (em_min is null) OR (em_max is null))"; - /* NOTE '... OR (em_min is null)' statement causes to include 2D-continuum datasets if they overlap in sky - * It is the legacy-search behaviour - however is that useful ? - */ - } + if(subsurveyId != null) + { + /* FIXME replace this implementation with exact string match once survey_id is defined / added to obs_core */ - if(subsurveyId != null) - { - /* FIXME replace this implementation with exact string match once survey_id is defined / added to obs_core */ - - String addSS = ""; - if((subsurveyId.surveyName != null) && (subsurveyId.surveyName.length() > 0)) - addSS += "(obs_collection LIKE '" + subsurveyId.surveyName + "%')"; - - if((subsurveyId.species != null) && (subsurveyId.species.length() > 0) ) - { - if(addSS.length() > 0) addSS += " OR "; - addSS += "(obs_collection LIKE '%" + subsurveyId.species + "%')"; - } - if((subsurveyId.transition != null) && (subsurveyId.transition.length() > 0) ) - { - if(addSS.length() > 0) addSS += " OR "; - addSS += "(obs_collection LIKE '%" + subsurveyId.transition + "')"; - }; - - if(addSS.length() > 0) theQuery += " AND (" + addSS + ")"; - } + String addSS = ""; + if((subsurveyId.surveyName != null) && (subsurveyId.surveyName.length() > 0)) + addSS += "(obs_collection LIKE '" + subsurveyId.surveyName + "%')"; + + if((subsurveyId.species != null) && (subsurveyId.species.length() > 0) ) + { + if(addSS.length() > 0) addSS += " OR "; + addSS += "(obs_collection LIKE '%" + subsurveyId.species + "%')"; + } + if((subsurveyId.transition != null) && (subsurveyId.transition.length() > 0) ) + { + if(addSS.length() > 0) addSS += " OR "; + addSS += "(obs_collection LIKE '%" + subsurveyId.transition + "')"; + }; + + if(addSS.length() > 0) theQuery += " AND (" + addSS + ")"; + } - //theQuery += " ORDER BY obs_collection"; + //theQuery += " ORDER BY obs_collection"; - LOGGER.info(theQuery); + LOGGER.info(theQuery); List<String> pubdidList = new ArrayList<>(); @@ -196,18 +203,16 @@ public class DbPSearch String commaSepPubdids = String.join("\',\'", pubdidArr); - String theQuery; //String theQuery ="SELECT dataproduct_type,obs_publisher_did,obs_collection,polygon_region_galactic,access_url,em_min,em_max," - - // FIXME coord sys read from somwehere - if(true) - { // GALACTIC + String theQuery; + if(coord.skySystem.equals("GALACTIC")) + { theQuery ="SELECT *," + inputRegion + " <@ polygon_region_galactic AS inputInsideDb, " + inputRegion + " @> polygon_region_galactic AS dbInsideInput FROM obscore WHERE (obs_publisher_did IN (\'"+commaSepPubdids+"\'))"; } else - { // ICRS + { theQuery ="SELECT *," + inputRegion + " <@ polygon_region AS inputInsideDb, " + inputRegion + " @> polygon_region AS dbInsideInput FROM obscore WHERE (obs_publisher_did IN (\'"+commaSepPubdids+"\'))";