Loading data-discovery/src/main/java/vlkb/search/DbPSearch.java +230 −223 Original line number Diff line number Diff line Loading @@ -117,12 +117,12 @@ public class DbPSearch List<String> pubdidList = new ArrayList<>(); LOGGER.info("Connecting to: " + dbConn.uri() + " with optional user/pwd: " + dbConn.userName() +" / "+ dbConn.password() ); try( Connection conn = DriverManager.getConnection(dbConn.uri(), dbConn.userName(), dbConn.password()); Statement st = conn.createStatement(); ResultSet res = st.executeQuery(theQuery);) { //ResultSet res = doQuery(theQuery); while (res.next()) { Loading @@ -136,12 +136,6 @@ public class DbPSearch logSqlExInfo(se); se.printStackTrace(); } /* catch (ClassNotFoundException e) { LOGGER.info("DB driver "+ DB_DRIVER +" not found: " + e.getMessage()); e.printStackTrace(); } */ String[] pubdidArr = pubdidList.toArray(new String[0]); Loading @@ -153,7 +147,7 @@ public class DbPSearch public FormatResponseFilter.ObsCore[] queryOutputData(String[] pubdidArr, Coord coord, SubsurveyId subsurveyId) public FormatResponseFilter.ObsCore[] queryOutputData(String[] pubdidArr, Coord coord/*, SubsurveyId subsurveyId*/) { LOGGER.info(""); double lon = coord.lon; Loading Loading @@ -200,15 +194,28 @@ 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," String theQuery ="SELECT *," // FIXME coord sys read from somwehere if(true) { // 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+"\'))"; } theQuery += " ORDER BY obs_collection"; //LOGGER.info(theQuery); LOGGER.info(theQuery); List<FormatResponseFilter.ObsCore> obsCoreList = new ArrayList<>(); Loading data-discovery/src/main/java/vlkb/webapi/FormatResponseFilter.java +20 −13 Original line number Diff line number Diff line Loading @@ -6,10 +6,16 @@ import java.util.Map; import java.io.*; import javax.servlet.*; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; import javax.servlet.http.*; import java.nio.charset.Charset; Loading Loading @@ -52,6 +58,7 @@ public class FormatResponseFilter implements Filter final String RESPONSE_ENCODING = "UTF-8"; protected Subsurvey[] dbSubsurveyArr = null; private String reqQueryString; @Override Loading @@ -67,35 +74,35 @@ public class FormatResponseFilter implements Filter } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LOGGER.info("trace"); LOGGER.info("REQUEST START ============================================================================================="); FormatResponseWrapper pubdidWrapper = new FormatResponseWrapper((HttpServletResponse) response); FormatResponseWrapper responseWrapper = new FormatResponseWrapper((HttpServletResponse) response); chain.doFilter(request, pubdidWrapper); chain.doFilter(request, responseWrapper); long startTime_msec = System.currentTimeMillis(); PrintWriter responseWriter = ((HttpServletResponse)response).getWriter(); if (true) //if (pubdidWrapper.getContentType().contains("text/plain")) //if (responseWrapper.getContentType().contains("text/plain")) { Dataset[] datasetArr = getOutputData( pubdidWrapper.getPubdidArr(), pubdidWrapper.coord, pubdidWrapper.subsurveyId, pubdidWrapper.queryString, responseWrapper.getPubdidArr(), responseWrapper.coord, // VLKB: calc ovelrap-code in Spectrum responseWrapper.queryString, settings.serviceUrls.cutoutUrl()); SearchOutputData searchOutputData = SearchOutputData.marshall( datasetArr, pubdidWrapper.auth, pubdidWrapper.coord, pubdidWrapper.subsurveyId, responseWrapper.auth, responseWrapper.coord, // VLKB: calc Vertices responseWrapper.subsurveyId, settings.serviceUrls.mergeUrl(), dbSubsurveyArr); Loading Loading @@ -182,7 +189,7 @@ public class FormatResponseFilter implements Filter private Dataset[] getOutputData(String[] pubdidArr, Coord coord,SubsurveyId subsurveyId, String queryString, String fitsRemotePath) private Dataset[] getOutputData(String[] pubdidArr, Coord coord,/*SubsurveyId subsurveyId,*/ String queryString, String fitsRemotePath) { LOGGER.info("trace"); Loading @@ -192,7 +199,7 @@ public class FormatResponseFilter implements Filter dbps = new DbPSearch(); } FormatResponseFilter.ObsCore[] obsCoreArr = dbps.queryOutputData(pubdidArr, coord, subsurveyId); FormatResponseFilter.ObsCore[] obsCoreArr = dbps.queryOutputData(pubdidArr, coord/*, subsurveyId*/); return convert(obsCoreArr, coord, queryString, fitsRemotePath); } Loading data-discovery/src/main/java/vlkb/webapi/SearchServlet.java +6 −5 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet legacyLogEntry(request); Map<String, String[]> params = request.getParameterMap(); String queryString = request.getQueryString(); try { Loading Loading @@ -73,11 +74,11 @@ public class SearchServlet extends javax.servlet.http.HttpServlet /* collect all search description and set to wrapped response */ FormatResponseWrapper pubdidWrapper = (FormatResponseWrapper) response; pubdidWrapper.setPubdidArr(pubdidArr); pubdidWrapper.coord = coord; pubdidWrapper.subsurveyId = subsurveyId; // FIXME set here or not ? pubdidWrapper.queryString = ??; FormatResponseWrapper responseWrapper = (FormatResponseWrapper) response; responseWrapper.setPubdidArr(pubdidArr); responseWrapper.coord = coord; responseWrapper.subsurveyId = subsurveyId; responseWrapper.queryString = queryString; } else { Loading Loading
data-discovery/src/main/java/vlkb/search/DbPSearch.java +230 −223 Original line number Diff line number Diff line Loading @@ -117,12 +117,12 @@ public class DbPSearch List<String> pubdidList = new ArrayList<>(); LOGGER.info("Connecting to: " + dbConn.uri() + " with optional user/pwd: " + dbConn.userName() +" / "+ dbConn.password() ); try( Connection conn = DriverManager.getConnection(dbConn.uri(), dbConn.userName(), dbConn.password()); Statement st = conn.createStatement(); ResultSet res = st.executeQuery(theQuery);) { //ResultSet res = doQuery(theQuery); while (res.next()) { Loading @@ -136,12 +136,6 @@ public class DbPSearch logSqlExInfo(se); se.printStackTrace(); } /* catch (ClassNotFoundException e) { LOGGER.info("DB driver "+ DB_DRIVER +" not found: " + e.getMessage()); e.printStackTrace(); } */ String[] pubdidArr = pubdidList.toArray(new String[0]); Loading @@ -153,7 +147,7 @@ public class DbPSearch public FormatResponseFilter.ObsCore[] queryOutputData(String[] pubdidArr, Coord coord, SubsurveyId subsurveyId) public FormatResponseFilter.ObsCore[] queryOutputData(String[] pubdidArr, Coord coord/*, SubsurveyId subsurveyId*/) { LOGGER.info(""); double lon = coord.lon; Loading Loading @@ -200,15 +194,28 @@ 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," String theQuery ="SELECT *," // FIXME coord sys read from somwehere if(true) { // 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+"\'))"; } theQuery += " ORDER BY obs_collection"; //LOGGER.info(theQuery); LOGGER.info(theQuery); List<FormatResponseFilter.ObsCore> obsCoreList = new ArrayList<>(); Loading
data-discovery/src/main/java/vlkb/webapi/FormatResponseFilter.java +20 −13 Original line number Diff line number Diff line Loading @@ -6,10 +6,16 @@ import java.util.Map; import java.io.*; import javax.servlet.*; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponseWrapper; import javax.servlet.http.*; import java.nio.charset.Charset; Loading Loading @@ -52,6 +58,7 @@ public class FormatResponseFilter implements Filter final String RESPONSE_ENCODING = "UTF-8"; protected Subsurvey[] dbSubsurveyArr = null; private String reqQueryString; @Override Loading @@ -67,35 +74,35 @@ public class FormatResponseFilter implements Filter } @Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { LOGGER.info("trace"); LOGGER.info("REQUEST START ============================================================================================="); FormatResponseWrapper pubdidWrapper = new FormatResponseWrapper((HttpServletResponse) response); FormatResponseWrapper responseWrapper = new FormatResponseWrapper((HttpServletResponse) response); chain.doFilter(request, pubdidWrapper); chain.doFilter(request, responseWrapper); long startTime_msec = System.currentTimeMillis(); PrintWriter responseWriter = ((HttpServletResponse)response).getWriter(); if (true) //if (pubdidWrapper.getContentType().contains("text/plain")) //if (responseWrapper.getContentType().contains("text/plain")) { Dataset[] datasetArr = getOutputData( pubdidWrapper.getPubdidArr(), pubdidWrapper.coord, pubdidWrapper.subsurveyId, pubdidWrapper.queryString, responseWrapper.getPubdidArr(), responseWrapper.coord, // VLKB: calc ovelrap-code in Spectrum responseWrapper.queryString, settings.serviceUrls.cutoutUrl()); SearchOutputData searchOutputData = SearchOutputData.marshall( datasetArr, pubdidWrapper.auth, pubdidWrapper.coord, pubdidWrapper.subsurveyId, responseWrapper.auth, responseWrapper.coord, // VLKB: calc Vertices responseWrapper.subsurveyId, settings.serviceUrls.mergeUrl(), dbSubsurveyArr); Loading Loading @@ -182,7 +189,7 @@ public class FormatResponseFilter implements Filter private Dataset[] getOutputData(String[] pubdidArr, Coord coord,SubsurveyId subsurveyId, String queryString, String fitsRemotePath) private Dataset[] getOutputData(String[] pubdidArr, Coord coord,/*SubsurveyId subsurveyId,*/ String queryString, String fitsRemotePath) { LOGGER.info("trace"); Loading @@ -192,7 +199,7 @@ public class FormatResponseFilter implements Filter dbps = new DbPSearch(); } FormatResponseFilter.ObsCore[] obsCoreArr = dbps.queryOutputData(pubdidArr, coord, subsurveyId); FormatResponseFilter.ObsCore[] obsCoreArr = dbps.queryOutputData(pubdidArr, coord/*, subsurveyId*/); return convert(obsCoreArr, coord, queryString, fitsRemotePath); } Loading
data-discovery/src/main/java/vlkb/webapi/SearchServlet.java +6 −5 Original line number Diff line number Diff line Loading @@ -43,6 +43,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet legacyLogEntry(request); Map<String, String[]> params = request.getParameterMap(); String queryString = request.getQueryString(); try { Loading Loading @@ -73,11 +74,11 @@ public class SearchServlet extends javax.servlet.http.HttpServlet /* collect all search description and set to wrapped response */ FormatResponseWrapper pubdidWrapper = (FormatResponseWrapper) response; pubdidWrapper.setPubdidArr(pubdidArr); pubdidWrapper.coord = coord; pubdidWrapper.subsurveyId = subsurveyId; // FIXME set here or not ? pubdidWrapper.queryString = ??; FormatResponseWrapper responseWrapper = (FormatResponseWrapper) response; responseWrapper.setPubdidArr(pubdidArr); responseWrapper.coord = coord; responseWrapper.subsurveyId = subsurveyId; responseWrapper.queryString = queryString; } else { Loading