Class FetchContext

java.lang.Object
no.sikt.graphitron.generators.context.FetchContext

public class FetchContext extends Object
A helper class to handle traversal of nested types in queries. Since such queries will require nested layers of rows, this class can generate the next "iteration" of itself for handling deeper layers.
  • Constructor Details

    • FetchContext

      public FetchContext(ProcessedSchema processedSchema, ObjectField referenceObjectField, RecordObjectSpecification<?> previousObject, boolean addAllJoinsToJoinSet)
      Parameters:
      referenceObjectField - The referring field that contains an object.
      previousObject - Object of origin for this context.
    • FetchContext

      public FetchContext(ProcessedSchema processedSchema, ObjectField referenceObjectField, RecordObjectSpecification<?> previousObject, boolean addAllJoinsToJoinSet, boolean useTableWithoutAliasInFirstStep)
  • Method Details

    • getJoinSet

      public Set<SQLJoinStatement> getJoinSet()
      Returns:
      Set of joins created by this context.
    • getAliasSet

      public Set<AliasWrapper> getAliasSet()
      Returns:
      Set of aliases created by this and any other context created from this one.
    • getGraphPath

      public String getGraphPath()
      Returns:
      The path to this context in the schema itself. Used to correctly check selection sets.
    • getReferenceObject

      public RecordObjectSpecification<?> getReferenceObject()
      Returns:
      The referred object being processed in the current context.
    • getCurrentJoinSequence

      public JoinListSequence getCurrentJoinSequence()
      Returns:
      The table join path or alias where the columns are expected to be found.
    • getConditionList

      public List<no.sikt.graphitron.javapoet.CodeBlock> getConditionList()
      Returns:
      List of all conditions created up to this point.
    • getReferenceTable

      public JOOQMapping getReferenceTable()
      Returns:
      The reference table the reference field points to.
    • getPreviousTable

      public JOOQMapping getPreviousTable()
      Returns:
      The previously used reference table.
    • getTargetTable

      public JOOQMapping getTargetTable()
      Returns:
      The target table of this context.
    • getTargetTableName

      public String getTargetTableName()
      Returns:
      The target table name of this context.
    • getSourceAlias

      public String getSourceAlias()
    • getTargetAlias

      public String getTargetAlias()
      Returns:
      The target table alias of this context.
    • getReferenceOrPreviousTable

      public JOOQMapping getReferenceOrPreviousTable()
      Returns:
      The reference table which fields on this layer are taken from.
    • getReferenceObjectField

      public GenerationField getReferenceObjectField()
      Returns:
      The reference field which points to the reference object for this layer.
    • getConditionSourceFields

      public List<GenerationField> getConditionSourceFields()
      Returns:
      The sources for conditions that could not be applied in previous steps.
    • getResolverKey

      public KeyWrapper getResolverKey()
    • hasApplicableTable

      public boolean hasApplicableTable()
    • hasNonSubqueryFields

      public boolean hasNonSubqueryFields()
    • hasPreviousContext

      public boolean hasPreviousContext()
    • getShouldUseOptional

      public boolean getShouldUseOptional()
    • withShouldUseOptional

      public FetchContext withShouldUseOptional(boolean shouldUseOptional)
    • shouldUseEnhancedNullOnAllNullCheck

      public boolean shouldUseEnhancedNullOnAllNullCheck()
      Returns:
      Should this layer apply an expanded null check?
    • setParentContextShouldUseEnhancedNullOnAllNullCheck

      public void setParentContextShouldUseEnhancedNullOnAllNullCheck()
      Override the previous layer's use of an expanded null check.
    • nextContext

      public FetchContext nextContext(GenerationField referenceObjectField)
      Returns:
      The next iteration of this context based on the provided reference field.
    • forVirtualField

      public FetchContext forVirtualField(VirtualSourceField field)
    • iterateJoinSequenceFor

      public JoinListSequence iterateJoinSequenceFor(GenerationField field)
      Iterate the table sequence as if several context layers were traversed with the provided references.
      Returns:
      The new join sequence, with the provided join sequence extended by all references in this layer's reference field, or other appropriate start points for a sequence.
    • iterateJoinSequence

      public JoinListSequence iterateJoinSequence(JoinListSequence previousSequence)
      Iterate the table sequence as if several context layers were traversed.
      Returns:
      The new join sequence, with the provided join sequence extended by all references in this layer's reference field, or other appropriate start points for a sequence.
    • createJoinOnExplicitPathFor

      public SQLJoinStatement createJoinOnExplicitPathFor(FieldReference fRef, JOOQMapping keyOverride, JoinListSequence joinSequence, JOOQMapping tableNameBackup, boolean isNullable)
      /**
      Returns:
      A join statement based on a key reference using path
    • renderQuerySource

      public no.sikt.graphitron.javapoet.CodeBlock renderQuerySource(JOOQMapping localTable)