java.lang.Object
qupath.ext.biop.servers.omero.raw.utils.Utils

public class Utils extends Object
Utils class regrouping tools that are not restricted to OMERO.
  • Field Details

  • Constructor Details

    • Utils

      public Utils()
  • Method Details

    • getCurrentDateAndHour

      public static String getCurrentDateAndHour()
      Returns:
      formatted date
    • getErrorStackTraceAsString

      public static String getErrorStackTraceAsString(Exception e)
      Parameters:
      e - the exception
      Returns:
      the exception stack trace as a formatted string
    • infoLog

      public static void infoLog(org.slf4j.Logger logger, String title, String message, boolean qpNotif)
      Info Logger to inform in QuPath GUI and / or in the logger window
      Parameters:
      title - notification title
      message - notification message
      qpNotif - true to display a QuPath notification
    • infoLog

      public static void infoLog(org.slf4j.Logger logger, String title, String message, Exception e, boolean qpNotif)
      Info Logger to inform in QuPath GUI and / or in the logger window
      Parameters:
      title - notification title
      message - notification message
      e - the exception
      qpNotif - true to display a QuPath notification
    • errorLog

      public static void errorLog(org.slf4j.Logger logger, String title, String message, boolean qpNotif)
      Error Logger to inform in QuPath GUI and / or in the logger window
      Parameters:
      title - notification title
      message - notification message
      qpNotif - true to display a QuPath notification
    • errorLog

      public static void errorLog(org.slf4j.Logger logger, String title, String message, Exception e, boolean qpNotif)
      Error Logger to inform in QuPath GUI and / or in the logger window
      Parameters:
      title - notification title
      message - notification message
      e - the exception
      qpNotif - true to display a QuPath notification
    • warnLog

      public static void warnLog(org.slf4j.Logger logger, String title, String message, boolean qpNotif)
      Warning Logger to inform in QuPath GUI and / or in the logger window
      Parameters:
      title - notification title
      message - notification message
      qpNotif - true to display a QuPath notification
    • warnLog

      public static void warnLog(org.slf4j.Logger logger, String title, String message, Exception e, boolean qpNotif)
      Warning Logger to inform in QuPath GUI and / or in the logger window
      Parameters:
      title - notification title
      message - notification message
      e - the exception
      qpNotif - true to display a QuPath notification
    • splitNewAndExistingKeyValues

      public static Map<String,Map<String,String>> splitNewAndExistingKeyValues(Map<String,String> reference, Map<String,String> target)
      Splits the "target" map into two parts : one part containing key/values that are referenced in the "reference" map and the other containing remaining key/values that are not referenced in the "reference".

      • The new key values can be accessed with NEW_KVP key
      • The existing key values can be accessed with EXISTING_KVP key

      Parameters:
      reference - map of referenced key-value pairs
      target - map of new key-value pairs that should be checked against the referenced ones
      Returns:
      Map of new kvp and existing kvp maps
    • checkUniqueKeyInAnnotationMap

      protected static boolean checkUniqueKeyInAnnotationMap(List<omero.model.NamedValue> keyValues)
      Try to solve an error in OMERO regarding the keys creation. On OMERO, it is possible to have two identical keys with a different value. This should normally never append. This method checks if all keys are unique and output false if there is at least two identical keys.
      Parameters:
      keyValues - to check
      Returns:
      true if all keys unique ; false otherwise
    • convertMapAnnotationWrapperToMap

      protected static Map<String,String> convertMapAnnotationWrapperToMap(fr.igred.omero.annotations.MapAnnotationWrapper mapAnnotationWrapper)
      Utils to convert the MapAnnotationWrapper object into a map of the OMERO key-values
      Parameters:
      mapAnnotationWrapper -
      Returns:
    • flattenMapAnnotationWrapperList

      protected static fr.igred.omero.annotations.MapAnnotationWrapper flattenMapAnnotationWrapperList(List<fr.igred.omero.annotations.MapAnnotationWrapper> mapAnnotationWrappers)
      Create one single MapAnnotationWrapper object from a list of them
      Parameters:
      mapAnnotationWrappers -
      Returns:
    • buildCSVFileFromListsOfStrings

      protected static File buildCSVFileFromListsOfStrings(LinkedHashMap<String,List<String>> parentTable, String name)
      Convert a map into a CSV file
      Parameters:
      parentTable - the map containing headers and values
      name - file name without the extension.
      Returns:
      the saved CSV file
    • buildOmeroTableFromListsOfStrings

      protected static omero.gateway.model.TableData buildOmeroTableFromListsOfStrings(LinkedHashMap<String,List<String>> parentTable, OmeroRawClient client)
      Convert a map into an OMERO.table
      Parameters:
      parentTable - the map containing headers and values
      client - the client that handles the OMERO connection
      Returns:
      the OMERO table
    • buildCSVFileFromMeasurementTable

      protected static File buildCSVFileFromMeasurementTable(Collection<qupath.lib.objects.PathObject> pathObjects, qupath.lib.gui.measure.ObservableMeasurementTableData ob, long imageId, String name)
      Convert a QuPath measurement table into a CSV file, including the OMERO image ID on which the measurements are referring to.
      Parameters:
      pathObjects - QuPath annotations or detections objects
      ob - QuPath Measurements table for the current image
      imageId - the id of the current image
      name - file name
      Returns:
      CSV file of measurement table.
    • buildOmeroTableFromMeasurementTable

      protected static omero.gateway.model.TableData buildOmeroTableFromMeasurementTable(Collection<qupath.lib.objects.PathObject> pathObjects, qupath.lib.gui.measure.ObservableMeasurementTableData ob, fr.igred.omero.repository.ImageWrapper imageWrapper)
      Convert a QuPath measurement table to an OMERO table
      Parameters:
      pathObjects - QuPath annotations or detections objects
      ob - QuPath Measurements table for the current image
      imageWrapper - current OMERO image object
      Returns:
      The corresponding OMERO.Table
    • buildListsOfStringsFromMeasurementTable

      protected static void buildListsOfStringsFromMeasurementTable(LinkedHashMap<String,List<String>> parentTable, qupath.lib.gui.measure.ObservableMeasurementTableData ob, Collection<qupath.lib.objects.PathObject> pathObjects, long imageId)
      Populate a map with new measurements coming from a measurement table of new pathObjects.
      Parameters:
      parentTable - LinkedHashMap to populate. Other type of maps will not work
      ob - QuPath Measurements table for the current image
      pathObjects - QuPath annotations or detections objects
      imageId - OMERO ID of the current image
    • createAndSaveFile

      protected static File createAndSaveFile(String path, String content)
      Create a file in the given path, with the given content, and save it
      Parameters:
      path - location + filename of the path
      content - file content
      Returns:
      the saved file