Class LddUtils

java.lang.Object
gov.nasa.pds.registry.common.dd.LddUtils

public class LddUtils extends Object
Simple methods to work with PDS LDD JSON files (data dictionary files).
Author:
karpenko
  • Constructor Details

    • LddUtils

      public LddUtils()
  • Method Details

    • getPds2EsDataTypeCfgFile

      public static File getPds2EsDataTypeCfgFile(String homeEnvVar) throws Exception
      Get default PDS to Elasticsearch data type mapping configuration file.
      Parameters:
      homeEnvVar - Home environment variable name, such as "HARVEST_HOME".
      Returns:
      File pointing to default configuration file.
      Throws:
      Exception - an exception
    • parseLddDate

      public static Date parseLddDate(String dateStr) throws ParseException
      Throws:
      ParseException
    • parseLddDate

      public static Date parseLddDate(String dateStr, @Nonnull String handleLeapSecondNotation) throws ParseException
      Throws:
      ParseException
    • lddDateToIsoInstantString

      public static String lddDateToIsoInstantString(String dateStr) throws Exception
      Convert LDD date, e.g., "Wed Dec 23 10:16:28 EST 2020" to ISO Instant format, e.g., "2020-12-23T15:16:28Z".
      Parameters:
      dateStr - LDD date string from PDS LDD JSON file.
      Returns:
      ISO Instant formatted date
      Throws:
      Exception - an exception
    • lddDateToIsoInstant

      public static Instant lddDateToIsoInstant(String dateStr) throws Exception
      Convert LDD date, e.g., "Wed Dec 23 10:16:28 EST 2020" to ISO Instant format, e.g., "2020-12-23T15:16:28Z".
      Parameters:
      dateStr - LDD date string from PDS LDD JSON file.
      Returns:
      ISO Instant formatted date
      Throws:
      Exception - an exception
    • listLddNamespaces

      public static Set<String> listLddNamespaces(File lddFile) throws Exception
      Parse JSON LDD file and list all namespaces
      Parameters:
      lddFile - JSON LDD file
      Returns:
      a set of namespaces
      Throws:
      Exception - an exception
    • getLddNamespace

      public static String getLddNamespace(File lddFile) throws Exception
      Extract LDD namespace. If there are more than one namespace, throw an exception.
      Parameters:
      lddFile - JSON LDD file
      Returns:
      namespace (e.g., 'pds')
      Throws:
      Exception - an exception
    • getJsonLddUrlFromXsd

      public static String getJsonLddUrlFromXsd(String uri) throws Exception
      Get JSON LDD URL from XSD location
      Parameters:
      uri - XSD location URL
      Returns:
      JSON LDD URL
      Throws:
      Exception - an exception