Class BusinessKey

java.lang.Object
ubic.gemma.persistence.util.BusinessKey

public class BusinessKey extends Object
Methods to test business-key-related issues on objects. The 'checkValidKey' methods can be used to check whether an object has the required business key values filled in. An exception is thrown if they don't.

Hibernate 6 port: the Criteria-based API has been replaced with JPA Criteria. Each entity type exposes a matches(...) helper that contributes predicates to a query the caller already built (so the caller stays in control of read-only/flush-mode hints), and a convenience find(Session, X) that wraps the whole thing. The checkKey / checkValidKey methods are unchanged.

Author:
pavlidis
  • Constructor Details

    • BusinessKey

      public BusinessKey()
  • Method Details

    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, ArrayDesign> from, ArrayDesign arrayDesign)
    • find

      public static ArrayDesign find(Session session, ArrayDesign arrayDesign)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?,BioAssay> from, BioAssay bioAssay)
    • find

      public static BioAssay find(Session session, BioAssay bioAssay)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, BioMaterial> from, BioMaterial bioMaterial)
    • find

      public static BioMaterial find(Session session, BioMaterial bioMaterial)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, BioSequence> from, BioSequence bioSequence)
    • find

      public static BioSequence find(Session session, BioSequence bioSequence)
    • attachBioSequence

      public static void attachBioSequence(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?,?> parent, String propertyName, BioSequence bioSequence, List<jakarta.persistence.criteria.Predicate> preds)
      Restricts a parent query so that property propertyName matches a BioSequence by business key. Used by e.g. BlatResult / BlatAssociation finders.
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, Chromosome> from, Chromosome chromosome)
    • find

      public static Chromosome find(Session session, Chromosome chromosome)
      Find an existing Chromosome by its business key (name + taxon, optionally tightened by assemblyDatabase + sequence when present on the input).
      Throws:
      IllegalArgumentException - if the chromosome lacks a name or a taxon
      NonUniqueResultException - if more than one row matches the key
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, ? extends Contact> from, Contact contact)
    • find

      public static Contact find(Session session, Contact contact)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, ExperimentalFactor> from, ExperimentalFactor experimentalFactor)
    • find

      public static ExperimentalFactor find(Session session, ExperimentalFactor experimentalFactor)
    • find

      public static FactorValue find(Session session, FactorValue factorValue)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?,Gene> from, Gene gene, boolean stricter)
    • find

      public static Gene find(Session session, Gene gene)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, Gene2GOAssociation> from, Gene2GOAssociation g2g)
    • find

      public static Gene2GOAssociation find(Session session, Gene2GOAssociation g2g)
    • find

      public static GeneProduct find(Session session, GeneProduct geneProduct)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?,Taxon> from, Taxon taxon)
    • find

      public static Taxon find(Session session, Taxon taxon)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, ? extends Characteristic> from, Characteristic ontologyEntry)
    • find

      public static Characteristic find(Session session, Characteristic ontologyEntry)
    • find

      public static Unit find(Session session, Unit unit)
    • find

      public static ExpressionExperimentSubSet find(Session session, ExpressionExperimentSubSet entity)
    • matches

      public static List<jakarta.persistence.criteria.Predicate> matches(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?, QuantitationType> from, QuantitationType qt)
    • find

      public static QuantitationType find(Session session, QuantitationType qt)
      Find an existing QuantitationType whose full set of identifying fields equals the input's.
      Throws:
      IllegalArgumentException - if the QT lacks a name
      NonUniqueResultException - if more than one row matches the key
    • find

      @Nullable public static BioAssayDimension find(Session session, BioAssayDimension bioAssayDimension)
    • checkKey

      public static void checkKey(BioAssayDimension bioAssayDimension)
    • checkKey

      public static void checkKey(QuantitationType quantitationType)
    • attachDatabaseEntry

      public static void attachDatabaseEntry(jakarta.persistence.criteria.CriteriaBuilder cb, jakarta.persistence.criteria.From<?,?> parent, String propertyName, DatabaseEntry databaseEntry, List<jakarta.persistence.criteria.Predicate> preds)
      Restrict a parent query so a DatabaseEntry-typed property at propertyName matches by business key. Used by callers that build a query on a different entity referencing the DatabaseEntry.
    • checkKey

      public static void checkKey(BibliographicReference bibliographicReference)
    • checkKey

      public static void checkKey(Characteristic ontologyEntry)
    • checkKey

      public static void checkKey(Contact contact)
    • checkKey

      public static void checkKey(DatabaseEntry accession)
    • checkKey

      public static void checkKey(DesignElementDataVector designElementDataVector)
    • checkKey

      public static void checkKey(ExternalDatabase externalDatabase)
    • checkKey

      public static void checkKey(FactorValue factorValue)
    • checkKey

      public static void checkKey(Gene gene)
    • checkKey

      public static void checkKey(User user)
    • checkKey

      public static void checkKey(ExpressionExperimentSubSet entity)
    • checkValidKey

      public static void checkValidKey(ArrayDesign arrayDesign)
    • checkValidKey

      public static void checkValidKey(BioSequence bioSequence)
    • checkValidKey

      public static void checkValidKey(Chromosome chromosome)
    • checkValidKey

      public static void checkValidKey(DatabaseEntry databaseEntry)
    • checkValidKey

      public static void checkValidKey(ExperimentalFactor experimentalFactor)
    • checkValidKey

      public static void checkValidKey(Gene gene)
    • checkValidKey

      public static void checkValidKey(Gene2GOAssociation gene2GOAssociation)
    • checkValidKey

      public static void checkValidKey(GeneProduct geneProduct)
    • checkValidKey

      public static void checkValidKey(Taxon taxon)
    • checkValidKey

      public static void checkValidKey(Unit unit)