Class PrivateUtils

java.lang.Object
org.lfenergy.compas.sct.commons.util.PrivateUtils

public final class PrivateUtils extends Object
See Also:
  • Constructor Details

    • PrivateUtils

      public PrivateUtils()
  • Method Details

    • extractCompasPrivates

      public static <T> Stream<T> extractCompasPrivates(TBaseElement baseElement, Class<T> compasClass) throws ScdException
      Extract compas elements of class compasClass nested in private elements of the given baseElement.
      Type Parameters:
      T - Inference parameter stands for class compasClass
      Parameters:
      baseElement - element where to look for privates
      compasClass - class of privates to extract
      Returns:
      list of compas objects nested in the privates.
      Throws:
      ScdException - throws when inconsistency between types
    • getPrivateStream

      public static <T> Stream<T> getPrivateStream(List<TPrivate> privates, Class<T> compasClass)
    • extractCompasPrivate

      public static <T> Optional<T> extractCompasPrivate(TBaseElement baseElement, Class<T> compasClass) throws ScdException
      Extract a single compas element of class compasClass nested in private elements of a given baseElement. Throws an exception when there are more than 1 compas element of given compasClass nested inside privates of the baseElement.
      Type Parameters:
      T - Inference parameter stands for class compasClass
      Parameters:
      baseElement - element where to look for privates
      compasClass - class of privates to extract
      Returns:
      list of compas objects nested in the privates.
      Throws:
      ScdException - throws when inconsistency between types, or when more than 1 compas element is found
    • extractCompasICDHeader

      public static Optional<TCompasICDHeader> extractCompasICDHeader(TPrivate tPrivate) throws ScdException
      Gets Private CompasICDHeader from Private
      Parameters:
      tPrivate - Private contenting object to get as CompasICDHeader
      Returns:
      content of th Private as optional of TCompasICDHeader object
      Throws:
      ScdException - throws when inconsistency between types
    • removePrivates

      public static void removePrivates(TBaseElement baseElement, @NonNull @NonNull PrivateEnum privateEnum)
      Removes all privates of type privateEnum from baseElement
      Parameters:
      baseElement - baseElement containing privates
      privateEnum - enum type of private to remove
    • createPrivate

      public static TPrivate createPrivate(TCompasBay compasBay)
      Create Private of given type as parameter
      Parameters:
      compasBay - type of Private to create
      Returns:
      created Private
    • createPrivate

      public static TPrivate createPrivate(TCompasFunction compasFunction)
      Create Private of given type as parameter
      Parameters:
      compasFunction - type of Private to create
      Returns:
      created Private
    • createPrivate

      public static TPrivate createPrivate(TCompasICDHeader compasICDHeader)
      Create Private of given type as parameter
      Parameters:
      compasICDHeader - type of Private to create
      Returns:
      created Private
    • createPrivate

      public static TPrivate createPrivate(TCompasSclFileType compasSclFileType)
      Create Private of given type as parameter
      Parameters:
      compasSclFileType - type of Private to create
      Returns:
      created Private
    • createPrivate

      public static TPrivate createPrivate(TCompasSystemVersion compasSystemVersion)
      Create Private of given type as parameter
      Parameters:
      compasSystemVersion - type of Private to create
      Returns:
      created Private
    • createPrivate

      public static TPrivate createPrivate(List<TCompasTopo> compasTopos)
      Create a single Private of type COMPAS-Topo containing all given TCompasTopo
      Parameters:
      compasTopos - list of TCompasTopo
      Returns:
      created Private
    • createMapICDSystemVersionUuidAndSTDFile

      public static Map<String,PrivateLinkedToStds> createMapICDSystemVersionUuidAndSTDFile(List<SCL> stds)
      Sorts in map of ICD_SYSTEM_VERSION_UUID and related Private coupled with all corresponding STD for all given STD
      Parameters:
      stds - list of STD to short
      Returns:
      map of ICD_SYSTEM_VERSION_UUID attribute in IED/Private:COMPAS-ICDHeader and related Private coupled with all corresponding STD
    • checkSTDCorrespondanceWithLNodeCompasICDHeader

      public static void checkSTDCorrespondanceWithLNodeCompasICDHeader(Map<String,PrivateLinkedToStds> mapICDSystemVersionUuidAndSTDFile) throws ScdException
      Checks SCD and STD compatibilities by checking if there is at least one ICD_SYSTEM_VERSION_UUID in Substation/../LNode/Private COMPAS-ICDHeader of SCL not present in IED/Private COMPAS-ICDHeader of STD
      Parameters:
      mapICDSystemVersionUuidAndSTDFile - map of ICD_SYSTEM_VERSION_UUID and list of corresponding STD
      Throws:
      ScdException - throws when there are several STD files corresponding to ICD_SYSTEM_VERSION_UUID from Substation/../LNode/Private COMPAS-ICDHeader of SCL
    • stdCheckFormatExceptionMessage

      public static String stdCheckFormatExceptionMessage(TPrivate key) throws ScdException
      Creates formatted message including data's of Private for Exception
      Parameters:
      key - Private causing exception
      Returns:
      formatted message
      Throws:
      ScdException - throws when parameter not present in Private
    • streamIcdHeaders

      public static Stream<IcdHeader> streamIcdHeaders(SCL scd)
      Creates stream of IcdHeader for all Privates COMPAS-ICDHeader in /Substation of SCL
      Parameters:
      scd - SCL file in which Private should be found
      Returns:
      stream of COMPAS-ICDHeader Private
    • comparePrivateCompasICDHeaders

      public static boolean comparePrivateCompasICDHeaders(TPrivate iedPrivate, TPrivate scdPrivate) throws ScdException
      Compares if two Private:COMPAS-ICDHeader have all attributes equal except IEDNane, BayLabel and IEDinstance
      Parameters:
      iedPrivate - Private of IED from STD to compare
      scdPrivate - Private of LNode fro SCD to compare
      Returns:
      Boolean value of check result
      Throws:
      ScdException - throws when Private is not COMPAS_ICDHEADER one
    • copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate

      public static void copyCompasICDHeaderFromLNodePrivateIntoSTDPrivate(TPrivate stdPrivate, TCompasICDHeader compasICDHeader) throws ScdException
      Copy Private COMPAS_ICDHEADER from LNode of SCD into Private COMPAS_ICDHEADER from IED of STD
      Parameters:
      stdPrivate - Private of IED from STD in which to copy new data
      compasICDHeader - Private of IED from STD from which new data are taken
      Throws:
      ScdException - throws when Private is not COMPAS_ICDHEADER one