Commit 86d69371 authored by Robert Butora's avatar Robert Butora
Browse files

chooses Resolver on Servlet init (if DbUri set) and modifies Resolver's both...

chooses Resolver on Servlet init (if DbUri set) and modifies Resolver's both implementations to return subsurveyId (in ResolverFromId subsurveyId not implemented yet only API)
parent 70f41169
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ public class JdlMCutout

            FitsCard[] extraCards = null;

            Resolver rsl = new ResolverFromId();//settings.dbConn, subsurveys);
            Resolver rsl = new ResolverFromId(null);//settings.dbConn, subsurveys);
                                                //ResolverByObsCore rsl = new ResolverByObsCore(settings.dbConn, subsurveys);
            rsl.resolve(publisherDid);

+0 −5
Original line number Diff line number Diff line
@@ -19,11 +19,6 @@ public interface Vlkb
         throws IOException, InterruptedException;


   public CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, Subsurvey[] subsurveys)
         throws IOException, InterruptedException;



   public MCutResult doMCutout(String jdlJson)
      throws IOException, InterruptedException;
+25 −42
Original line number Diff line number Diff line
@@ -33,11 +33,14 @@ class VlkbAmqp implements Vlkb

   private Settings    settings   = null;
   private Subsurvey[] subsurveys = null;
   private Resolver    resolver   = null;

   public VlkbAmqp()
   {
      LOGGER.info("trace VlkbAmqp()");
      this.settings = Settings.getInstance();
      this.resolver = (settings.dbConn.isDbUriEmpty() ? new ResolverFromId(subsurveys)
            : new ResolverByObsCore(settings.dbConn, subsurveys));
   }


@@ -45,14 +48,19 @@ class VlkbAmqp implements Vlkb
   {
      LOGGER.info("trace VlkbAmqp(settings)");
      this.settings = settings;
      this.resolver = (settings.dbConn.isDbUriEmpty() ? new ResolverFromId(subsurveys)
            : new ResolverByObsCore(settings.dbConn, subsurveys));
   }



   public VlkbAmqp(Settings settings, Subsurvey[] subsurveys)
   {
      LOGGER.info("trace VlkbAmqp(settings, subsurveys)");
      this.settings = settings;
      this.subsurveys = subsurveys;
      this.resolver = (settings.dbConn.isDbUriEmpty() ? new ResolverFromId(subsurveys)
            : new ResolverByObsCore(settings.dbConn, subsurveys));
   }


@@ -101,51 +109,26 @@ class VlkbAmqp implements Vlkb



   public CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
   private CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, Subsurvey[] subsurveys)
         throws IOException, InterruptedException
      {
         LOGGER.info("trace");

         String relPathname;
         int hdunum;

         FitsCard[] extraCards = null;

         String dbUri = settings.dbConn.uri();

         if(settings.dbConn.isDbUriEmpty())
         {
            Resolver rsl = new ResolverFromId();
            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
         this.resolver.resolve(id);
         String relPathname = this.resolver.relPathname();
         int hdunum         = this.resolver.hdunum();
         String subsurveyId = this.resolver.obsCollection();

             Path path = Paths.get(rsl.relPathname());
             String storagePath = path.getParent().toString();
             extraCards = Subsurvey.subsurveysFindCardsByStoragePath(subsurveys, storagePath);
             */
         }
         else
         {
            ResolverByObsCore rsl = new ResolverByObsCore(settings.dbConn, subsurveys);
            rsl.resolve(id);
            relPathname = rsl.relPathname();
            hdunum      = rsl.hdunum();
            String subsurveyId = rsl.obsCollection();
         if(subsurveyId != null)
         {
            extraCards = Subsurvey.subsurveysFindCards(subsurveys, subsurveyId);
         }
         else
         {
               LOGGER.info("Resolver with Obscore returns subsurveyId null: no extraCards loaded.");
            }
            LOGGER.info("Resolver returns subsurveyId null: no extraCards loaded.");
         }

         final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file
@@ -209,7 +192,7 @@ class VlkbAmqp implements Vlkb
         boolean countNullValues)
   {
      // ResolverByObsCore rsl = new ResolverByObsCore(settings.dbConn, subsurveys);
      Resolver rsl = new ResolverFromId();//settings.dbConn, subsurveys);
      Resolver rsl = resolver;//new ResolverFromId();//settings.dbConn, subsurveys);
      rsl.resolve(publisherDid);

      FitsCard[] extraCards = null;
+23 −40
Original line number Diff line number Diff line
@@ -44,12 +44,15 @@ class VlkbCli implements Vlkb
   private Settings    settings   = null;
   private Subsurvey[] subsurveys = null;
   private Soda        soda       = null;
   private Resolver    resolver   = null;

   public VlkbCli()
   {
      LOGGER.info("trace VlkbCli()");
      this.settings = Settings.getInstance();
      soda = new SodaImpl(settings, subsurveys);
      this.soda = new SodaImpl(settings, subsurveys);
      this.resolver = (settings.dbConn.isDbUriEmpty() ? new ResolverFromId(subsurveys)
            : new ResolverByObsCore(settings.dbConn, subsurveys));
   }


@@ -58,6 +61,8 @@ class VlkbCli implements Vlkb
      LOGGER.info("trace VlkbCli(settings)");
      this.settings = settings;
      this.soda = new SodaImpl(settings, subsurveys);
      this.resolver = (settings.dbConn.isDbUriEmpty() ? new ResolverFromId(subsurveys)
            : new ResolverByObsCore(settings.dbConn, subsurveys));
   }


@@ -67,11 +72,14 @@ class VlkbCli implements Vlkb
      this.settings = settings;
      this.subsurveys = subsurveys;
      this.soda = new SodaImpl(settings, subsurveys);
      this.resolver = (settings.dbConn.isDbUriEmpty() ? new ResolverFromId(subsurveys)
            : new ResolverByObsCore(settings.dbConn, subsurveys));
   }





   public CutResult doMerge(String[] idArr, Coord coord, boolean countNullValues)
      throws FileNotFoundException, IOException
   {
@@ -171,51 +179,26 @@ class VlkbCli implements Vlkb
      }


   public CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
   private CutResult doFileById(String id, Pos pos, Band band, Time time, Pol pol, String pixels,
         boolean countNullValues, Subsurvey[] subsurveys)
         throws IOException, InterruptedException
      {
         LOGGER.info("trace");

         String relPathname;
         int hdunum;

         FitsCard[] extraCards = null;

         String dbUri = settings.dbConn.uri();

         if(settings.dbConn.isDbUriEmpty())
         {
            Resolver rsl = new ResolverFromId();
            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
         this.resolver.resolve(id);
         String relPathname = this.resolver.relPathname();
         int hdunum         = this.resolver.hdunum();
         String subsurveyId = this.resolver.obsCollection();

             Path path = Paths.get(rsl.relPathname());
             String storagePath = path.getParent().toString();
             extraCards = Subsurvey.subsurveysFindCardsByStoragePath(subsurveys, storagePath);
             */
         }
         else
         {
            ResolverByObsCore rsl = new ResolverByObsCore(settings.dbConn, subsurveys);
            rsl.resolve(id);
            relPathname = rsl.relPathname();
            hdunum      = rsl.hdunum();
            String subsurveyId = rsl.obsCollection();
         if(subsurveyId != null)
         {
            extraCards = Subsurvey.subsurveysFindCards(subsurveys, subsurveyId);
         }
         else
         {
               LOGGER.info("Resolver with Obscore returns subsurveyId null: no extraCards loaded.");
            }
            LOGGER.info("Resolver returns subsurveyId null: no extraCards loaded.");
         }

         final String DEFAULT_TIME_SYSTEM = "MJD_UTC"; // FIXME take from confif file
+1 −0
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@ interface Resolver

   public String relPathname();
   public int    hdunum();
   public String obsCollection();
}

Loading