Class MapLookupDao<POJO extends MapLookupPojo<POJO>>

java.lang.Object
tenapull.data.persistence.Dao<POJO>
tenapull.data.persistence.AbstractPojoLookupDao<POJO>
tenapull.data.persistence.MapLookupDao<POJO>
Type Parameters:
POJO - the type parameter

public class MapLookupDao<POJO extends MapLookupPojo<POJO>>
extends AbstractPojoLookupDao<POJO>
Dao used for map lookup pojos, where a DB record can be matched by a search map or the _match function. This pojo type is often (though not always) used for records with a composite candidate key (e.g. ScanHost, with a host_id and scan_id) but may also be used for immutable object lookups in place of a hash lookup for very simple object structures where the overhead of a hash may not be worth the indexing benefit it provides
  • Constructor Details

    • MapLookupDao

      public MapLookupDao​(java.lang.Class<POJO> pojoType) throws java.lang.IllegalArgumentException
      Instantiates a new MapLookupDao for the pojo type provided.
      Parameters:
      pojoType -
      Throws:
      java.lang.IllegalArgumentException - if a dao has already been instantiated for the provided pojoType
  • Method Details

    • checkedGetOrCreate

      protected POJO checkedGetOrCreate​(POJO pojo)
      Description copied from class: AbstractPojoLookupDao
      Abstract method to be implemented by subclasses, which is invoked after the instance array has already been checked for the instance without success (assuming the pojo had a primary key id set) and the pojo has already had its _prepare method invoked
      Specified by:
      checkedGetOrCreate in class AbstractPojoLookupDao<POJO extends MapLookupPojo<POJO>>
      Parameters:
      pojo - the pojo
      Returns:
      the pojo
    • finalizeResult

      protected POJO finalizeResult​(POJO pojo, POJO result)
      Description copied from class: AbstractPojoLookupDao
      Perform any needed final operations on the "canonical" pojo before returning it to the caller of getOrCreate. Typically, if the canonical pojo were a different instance than the one provided, the _set method would be called on the canonical instance to update it so it reflects the values of the new instance
      Specified by:
      finalizeResult in class AbstractPojoLookupDao<POJO extends MapLookupPojo<POJO>>
      Parameters:
      pojo - the pojo
      result - the result
      Returns:
      the pojo
    • checkedUnproxy

      protected POJO checkedUnproxy​(org.hibernate.proxy.HibernateProxy pojo)
      Description copied from class: Dao
      Invoked by unproxy after it has confirmed that the pojo is not null and is an uninitialized instance of HibernateProxy
      Overrides:
      checkedUnproxy in class Dao<POJO extends MapLookupPojo<POJO>>
      Parameters:
      pojo - the pojo
      Returns:
      the pojo
    • makeSearchMapFromJson

      public static java.util.Map<java.lang.String,​java.lang.Object> makeSearchMapFromJson​(com.fasterxml.jackson.databind.JsonNode searchMapNode) throws javax.json.JsonException
      Make a pojo search map from a json node
      Parameters:
      searchMapNode - the json node to make the search map for
      Returns:
      the search map
      Throws:
      javax.json.JsonException - if there is an error processing json
    • toString

      public java.lang.String toString()
      Overrides:
      toString in class Dao<POJO extends MapLookupPojo<POJO>>
    • get

      public static <P extends DbPojo,​ D extends Dao<P>> D get​(java.lang.Class<P> objectLookupPojoClass)
      Get the MapLookupDao for the provided pojo type
      Type Parameters:
      P - the type parameter
      D - the type parameter
      Parameters:
      objectLookupPojoClass - the object lookup pojo class
      Returns:
      the d