Commit 1b328341 authored by Robert Butora's avatar Robert Butora
Browse files

implements extraCards use when Resolver-by-ObsCore only (Resolve by ID does...

implements extraCards use when Resolver-by-ObsCore only (Resolve by ID does not have SubsurveyId so cannot have extraCards
parent a4f8ccd4
Loading
Loading
Loading
Loading
+30 −0
Original line number Diff line number Diff line
@@ -60,6 +60,25 @@ class Subsurvey
      throw new AssertionError(subsurvey_id + " not found in surveys table");
   }

   static public Subsurvey findSubsurveyByStoragePath(Subsurvey[] dbSubsurveys, String storagePath)
   {
      LOGGER.info("trace storagePath: " + storagePath);

      for(Subsurvey curr : dbSubsurveys)
      {
         //curr.storage_path.strip("/");
         //storagePath.strip("/");

         if(curr.storage_path.equals(storagePath))
         {
            return curr;
         }
      }

      throw new AssertionError(storagePath + " storage-path not found in surveys table");
   }





@@ -74,6 +93,17 @@ class Subsurvey
      return keyRecords;
   }

   static public FitsCard[] subsurveysFindCardsByStoragePath(Subsurvey[] subsurveys, String storagePath)
   {
      if(subsurveys == null) return null;

      Subsurvey subsurvey = Subsurvey.findSubsurveyByStoragePath(subsurveys, storagePath);

      FitsCard[] keyRecords = FitsCard.convertToFitsCard(subsurvey.rf, subsurvey.vel_unit);

      return keyRecords;
   }




+17 −11
Original line number Diff line number Diff line
@@ -129,7 +129,7 @@ public class ServletCutout extends javax.servlet.http.HttpServlet


   protected CutResult doCutoutFile(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, String respFormat)
         boolean countNullValues)
         throws IOException, InterruptedException
   {
      LOGGER.info("trace");
@@ -137,6 +137,8 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
      String relPathname;
      int hdunum;

      FitsCard[] extraCards = null;

      String dbUri = settings.dbConn.uri();

      if(settings.dbConn.isDbUriEmpty())
@@ -145,6 +147,16 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
         rsl.resolve(id);
         relPathname = rsl.relPathname();
         hdunum      = rsl.hdunum();

         /* FIXME needs also match on filename - some subsurveys have the same storage-path,
          * and file-filter distiguishes frequences
          * OR
          * ivoid must include obs-collection

         Path path = Paths.get(rsl.relPathname());
         String storagePath = path.getParent().toString();
         extraCards = Subsurvey.subsurveysFindCardsByStoragePath(subsurveys, storagePath);
         */
      }
      else
      {
@@ -153,7 +165,6 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
         relPathname = rsl.relPathname();
         hdunum      = rsl.hdunum();
         String subsurveyId = rsl.obsCollection();
         FitsCard[] extraCards = null;
         if(subsurveyId != null)
         {
            extraCards = Subsurvey.subsurveysFindCards(subsurveys, subsurveyId);
@@ -162,16 +173,12 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
         {
            LOGGER.info("Resolver with Obscore returns subsurveyId null: no extraCards loaded.");
         }
         // FIXME use of extraCards not implemented
      }

      final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file

      //if(pos  != null) pos.setSystem(DEFAULT_SKY_SYSTEM);
      //if(band != null) band.setSystem(DEFAULT_SPEC_SYSTEM);
      //if(time != null) time.setSystem(DEFAULT_TIME_SYSTEM);

      CutResult cutResult = cutout.doFile(relPathname, hdunum, pos, band, time, pol, pixels, false, null);
      CutResult cutResult = cutout.doFile(relPathname, hdunum, pos, band, time, pol, pixels,
            countNullValues, extraCards);

      return cutResult;
   }
@@ -283,8 +290,7 @@ public class ServletCutout extends javax.servlet.http.HttpServlet
               boolean  countNullValues = vlkbReq_getNullValues(request);
               response.setContentType(respFormat);

               CutResult cutResult = doCutoutFile(id, pos, band, time, pol, pixels, countNullValues,
                     respFormat);
               CutResult cutResult = doCutoutFile(id, pos, band, time, pol, pixels, countNullValues);// FIXME wh? , respFormat);


               /* FIXME errors from engine not checked - cut-file might not have been created */