Package no.sikt.graphitron.generators.db
Class FetchDBMethodGenerator
java.lang.Object
no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator<T,ObjectDefinition>
no.sikt.graphitron.generators.abstractions.DBMethodGenerator<ObjectField>
no.sikt.graphitron.generators.db.FetchDBMethodGenerator
- All Implemented Interfaces:
MethodGenerator
- Direct Known Subclasses:
EntityDBFetcherMethodGenerator,FetchCountDBMethodGenerator,FetchMappedObjectDBMethodGenerator,FetchMultiTableDBMethodGenerator,FetchNodeImplementationDBMethodGenerator,FetchSingleTableInterfaceDBMethodGenerator
Abstract generator for various database fetching methods.
-
Field Summary
FieldsFields inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
dependencyMap, localObject, processedSchema -
Constructor Summary
ConstructorsConstructorDescriptionFetchDBMethodGenerator(ObjectDefinition localObject, ProcessedSchema processedSchema) -
Method Summary
Modifier and TypeMethodDescriptionprotected static CodeBlockcreateAliasDeclarations(Set<Alias> aliasSet) protected static CodeBlockcreateAliasDeclarations(Alias alias) protected CodeBlockcreateMapping(FetchContext context, List<? extends GenerationField> fieldsWithoutSplitting, HashMap<String, String> referenceFieldSources, List<CodeBlock> rowElements, LinkedHashSet<KeyWrapper> keySet) protected CodeBlockcreateOrderFieldsBlock(ObjectField referenceField, String actualRefTable, String tableName) protected CodeBlockcreateOrderFieldsDeclarationBlock(ObjectField referenceField, String actualRefTable, String tableName) protected CodeBlockprotected CodeBlockcreateSelectConditions(List<CodeBlock> conditionList, boolean hasWhere) protected CodeBlockcreateSelectJoins(Set<SQLJoinStatement> joinList) protected CodeBlockformatWhereContents(FetchContext context, String resolverKeyParamName, boolean isRoot, boolean isResolverRoot) protected CodeBlockgenerateCorrelatedSubquery(GenerationField field, FetchContext context) protected CodeBlockgenerateForScalarField(GenerationField field, FetchContext context) Generate a single argument in the row method call.protected CodeBlockgenerateForScalarField(GenerationField field, FetchContext context, boolean overrideEnum) Generate a single argument in the row method call.protected CodeBlockgenerateForUnionField(GenerationField field, FetchContext context) Generate select row for each object within the union fieldprotected CodeBlockgenerateSelectRow(FetchContext context) This method recursively generates one single row method call.protected CodeBlockgetInitialKey(FetchContext context) protected @NotNull InputConditionsgetInputConditions(ObjectField referenceField) getSelectCodeAndFieldSource(GenerationField field, FetchContext context) protected MethodSpec.BuildergetSpecBuilder(ObjectField referenceField, TypeName refTypeName, InputParser parser) protected Stringprotected CodeBlockwrapInField(CodeBlock contents) protected CodeBlockwrapInMultiset(CodeBlock contents) Methods inherited from class no.sikt.graphitron.generators.abstractions.DBMethodGenerator
getContextParameters, getDefaultSpecBuilder, getMethodParameters, getMethodParametersWithOrderField, iterableWrapTypeMethods inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
generate, getDataFetcherWiring, getDependencyMap, getLocalObject, getLocalTable, getTypeResolverWiring, inferFieldTypeNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface no.sikt.graphitron.generators.abstractions.MethodGenerator
generateAll
-
Field Details
-
resolverKeyParamName
-
isRoot
protected final boolean isRoot
-
-
Constructor Details
-
FetchDBMethodGenerator
-
-
Method Details
-
getInitialKey
-
createSelectJoins
- Parameters:
joinList- List of join statements that should be applied to a select query.- Returns:
- Code block containing all the join statements and their conditions.
-
createSelectConditions
- Parameters:
conditionList- List of conditional statements that should be appended after the where-statement.- Returns:
- Code block which declares all the extra conditions that will be used in a select query.
-
createAliasDeclarations
- Parameters:
aliasSet- Set of aliases to be defined.- Returns:
- Code block which declares all the aliases that will be used in a select query.
-
createAliasDeclarations
-
wrapInMultiset
-
wrapInField
-
generateSelectRow
This method recursively generates one single row method call. It deduces how each layer of row call should be structured by keeping track of joins and following field references.- Returns:
- Code block which contains the entire recursive structure of the row statement.
-
getSelectCodeAndFieldSource
protected org.apache.commons.lang3.tuple.Pair<CodeBlock,String> getSelectCodeAndFieldSource(GenerationField field, FetchContext context) -
createMapping
protected CodeBlock createMapping(FetchContext context, List<? extends GenerationField> fieldsWithoutSplitting, HashMap<String, String> referenceFieldSources, List<CodeBlock> rowElements, LinkedHashSet<KeyWrapper> keySet) -
generateForScalarField
Generate a single argument in the row method call. -
generateForScalarField
protected CodeBlock generateForScalarField(GenerationField field, FetchContext context, boolean overrideEnum) Generate a single argument in the row method call. -
generateForUnionField
Generate select row for each object within the union field -
formatWhereContents
protected CodeBlock formatWhereContents(FetchContext context, String resolverKeyParamName, boolean isRoot, boolean isResolverRoot) - Returns:
- Formatted CodeBlock for the where-statement and surrounding code. Applies conditions and joins.
-
getInputConditions
-
inferFieldNamingConvention
-
createSeekAndLimitBlock
-
createOrderFieldsDeclarationBlock
protected CodeBlock createOrderFieldsDeclarationBlock(ObjectField referenceField, String actualRefTable, String tableName) -
createOrderFieldsBlock
protected CodeBlock createOrderFieldsBlock(ObjectField referenceField, String actualRefTable, String tableName) -
getSpecBuilder
@NotNull protected MethodSpec.Builder getSpecBuilder(ObjectField referenceField, TypeName refTypeName, InputParser parser)
-