Commit 820f7bc5 authored by Robert Butora's avatar Robert Butora
Browse files

output: renames existing obsDataset fields to match naimng from ObsCore

parent 51ff7986
Loading
Loading
Loading
Loading
+56 −65
Original line number Diff line number Diff line
@@ -27,57 +27,6 @@ public class DbPSearch

   private static final String DB_DRIVER = "org.postgresql.Driver";

   public Subsurvey[] getSurveyTable()
   {
      List<Subsurvey> survList = new ArrayList<Subsurvey>();

      String theQuery = "SELECT name,species,transition,rest_frequency,restf_fits_unit,velocity_fits_unit,description FROM surveys";


      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);

	      if(res == null)
	      {
		      LOGGER.info("Query yielded no resuls: " + theQuery);
	      }
	      else
	      {
		      while (res.next())
		      {
			      Subsurvey surv = new Subsurvey();
			      surv.rf          = res.getDouble("rest_frequency");
			      surv.surveyname  = res.getString("name");
			      surv.species     = res.getString("species");
			      surv.transition  = res.getString("transition");
			      surv.rf_unit     = res.getString("restf_fits_unit");
			      surv.vel_unit    = res.getString("velocity_fits_unit");
			      surv.description = res.getString("description");

			      survList.add(surv);
		      }
	      }
      }
      catch (SQLException se)
      {
	      logSqlExInfo(se);
	      se.printStackTrace();
      }
/*      catch (ClassNotFoundException e)
      {
	      LOGGER.info("DB driver "+ DB_DRIVER +" not found: " + e.getMessage());
	      e.printStackTrace();
      }
*/
      return survList.toArray(new Subsurvey[0]);
   }


   public String[] queryOverlapingPubdid(Coord coord, SubsurveyId subsurveyId)
   {
	   LOGGER.info("trace");
@@ -251,7 +200,8 @@ public class DbPSearch
	   }

	   String commaSepPubdids  = String.join("\',\'", pubdidArr);
	   String theQuery ="SELECT dataproduct_type,obs_publisher_did,obs_collection,polygon_region_galactic,access_url,em_min,em_max," 
	   //String theQuery ="SELECT dataproduct_type,obs_publisher_did,obs_collection,polygon_region_galactic,access_url,em_min,em_max," 
	   String theQuery ="SELECT *," 
		   + inputRegion + " <@ polygon_region_galactic AS inputInsideDb, " 
		   + inputRegion + " @> polygon_region_galactic AS dbInsideInput FROM obscore WHERE (obs_publisher_did IN (\'"+commaSepPubdids+"\'))";

@@ -273,13 +223,11 @@ public class DbPSearch
		   while (res.next())
		   {
			   FormatResponseFilter.ObsDataset obsDataset = new FormatResponseFilter.ObsDataset();
			   obsDataset.data_type     = res.getString("dataproduct_type");
			   obsDataset.pubdid_str    = res.getString("obs_publisher_did");
			   obsDataset.subsurvey_id  = res.getString("obs_collection");
			   obsDataset.vertices_str  = res.getString("polygon_region_galactic");

			   obsDataset.dataproduct_type  = res.getString("dataproduct_type");
			   obsDataset.obs_publisher_did = res.getString("obs_publisher_did");
			   obsDataset.obs_collection    = res.getString("obs_collection");
			   obsDataset.access_url        = res.getString("access_url");
			   obsDataset.inputInsideDb = res.getBoolean("inputInsideDb");
			   obsDataset.dbInsideInput = res.getBoolean("dbInsideInput");

			   obsDataset.em_min = res.getDouble("em_min");
			   boolean em_min_valid = !res.wasNull();
@@ -287,6 +235,10 @@ public class DbPSearch
			   boolean em_max_valid = !res.wasNull();
			   obsDataset.em_valid = em_min_valid && em_max_valid;;

			   obsDataset.vertices_str  = res.getString("polygon_region_galactic");
			   obsDataset.inputInsideDb = res.getBoolean("inputInsideDb");
			   obsDataset.dbInsideInput = res.getBoolean("dbInsideInput");

			   obsDatasetList.add(obsDataset);
		   }

@@ -297,12 +249,6 @@ public class DbPSearch
		   logSqlExInfo(se);
		   se.printStackTrace();
	   }
/*	   catch (ClassNotFoundException e)
	   {
		   LOGGER.info("DB driver "+ DB_DRIVER +" not found: " + e.getMessage());
		   e.printStackTrace();
	   }
*/

	   FormatResponseFilter.ObsDataset[] cubes = obsDatasetList.toArray(new FormatResponseFilter.ObsDataset[0]);

@@ -358,6 +304,51 @@ public class DbPSearch
    return res;
      }
      */
/*   public Subsurvey[] getSurveyTable()
   {
      List<Subsurvey> survList = new ArrayList<Subsurvey>();

      String theQuery = "SELECT name,species,transition,rest_frequency,restf_fits_unit,velocity_fits_unit,description FROM surveys";


      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);

	      if(res == null)
	      {
		      LOGGER.info("Query yielded no resuls: " + theQuery);
	      }
	      else
	      {
		      while (res.next())
		      {
			      Subsurvey surv = new Subsurvey();
			      surv.rf          = res.getDouble("rest_frequency");
			      surv.surveyname  = res.getString("name");
			      surv.species     = res.getString("species");
			      surv.transition  = res.getString("transition");
			      surv.rf_unit     = res.getString("restf_fits_unit");
			      surv.vel_unit    = res.getString("velocity_fits_unit");
			      surv.description = res.getString("description");

			      survList.add(surv);
		      }
	      }
      }
      catch (SQLException se)
      {
	      logSqlExInfo(se);
	      se.printStackTrace();
      }
      return survList.toArray(new Subsurvey[0]);
   }
*/




+12 −10
Original line number Diff line number Diff line
@@ -154,17 +154,19 @@ public class FormatResponseFilter implements Filter
   /* FIXME type needed in DbPSearch */
   static class ObsDataset
   {
      String data_type;
      String pubdid_str;
      String subsurvey_id;
      String vertices_str;
      String dataproduct_type;
      String obs_publisher_did;
      String obs_collection;
      String access_url;
      boolean inputInsideDb;
      boolean dbInsideInput;

      boolean em_valid;
      double em_min;
      double em_max;
      boolean em_valid;

      String vertices_str;
      boolean inputInsideDb;
      boolean dbInsideInput;

   }


@@ -195,12 +197,12 @@ public class FormatResponseFilter implements Filter
      {
         Dataset dataset = new Dataset();

         dataset.subsurvey_id   = obsDataset.subsurvey_id;
         dataset.subsurvey_id   = obsDataset.obs_collection;
         dataset.overlapCodeSky = convertToOverlapCodeSky(obsDataset.inputInsideDb, obsDataset.dbInsideInput);
         dataset.overlapCodeVel = convertToOverlapCodeVel(coord, obsDataset.em_valid, obsDataset.em_min, obsDataset.em_max);
         dataset.overlapCode    = convertToOverlapCode(dataset.overlapCodeSky, dataset.overlapCodeVel);
         dataset.dataType       = obsDataset.data_type;
         dataset.publisherDid   = obsDataset.pubdid_str;
         dataset.dataType       = obsDataset.dataproduct_type;
         dataset.publisherDid   = obsDataset.obs_publisher_did;

         dataset.access.accessFileUrl   = obsDataset.access_url;
         dataset.access.accessCutoutUrl = fitsRemotePath + "?ID=" + dataset.publisherDid + "&" + queryString;