Package no.sikt.graphitron.generators.db
Class ServiceResultFetchDBMethodGenerator
java.lang.Object
no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator<ObjectField,ObjectDefinition>
no.sikt.graphitron.generators.abstractions.DBMethodGenerator<ObjectField>
no.sikt.graphitron.generators.db.FetchDBMethodGenerator
no.sikt.graphitron.generators.db.FetchMappedObjectDBMethodGenerator
no.sikt.graphitron.generators.db.ServiceResultFetchDBMethodGenerator
- All Implemented Interfaces:
MethodGenerator
Generator that creates DB fetch methods for fields where a @service returns a table-backed type.
Extends
FetchMappedObjectDBMethodGenerator with isRoot() returning false so that
the generated method includes resolver key parameters and WHERE clause for batch fetching by PK.-
Field Summary
Fields inherited from class no.sikt.graphitron.generators.db.FetchDBMethodGenerator
conditionsShouldFallbackToFalse, ELEMENT_NAME, resolverKeyParamNameFields inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
dependencyMap, localObject, processedSchema -
Constructor Summary
ConstructorsConstructorDescriptionServiceResultFetchDBMethodGenerator(ObjectDefinition localObject, ProcessedSchema processedSchema) -
Method Summary
Modifier and TypeMethodDescriptionList<no.sikt.graphitron.javapoet.MethodSpec> protected no.sikt.graphitron.javapoet.CodeBlockgetHelperMethodCallForNestedField(ObjectField field, FetchContext context) Generates a helper method call for nested record type fields.protected no.sikt.graphitron.javapoet.CodeBlockgetSelectBlockForRecord(ObjectField target, no.sikt.graphitron.javapoet.CodeBlock selectRowBlock, boolean isReferenceResolverField, InputParser parser) Determine the select block to use for record types.protected no.sikt.graphitron.javapoet.MethodSpec.BuildergetSpecBuilder(ObjectField referenceField, no.sikt.graphitron.javapoet.TypeName refTypeName, InputParser parser) Override to exclude input parameters from the DB method signature.protected booleanisRoot()Methods inherited from class no.sikt.graphitron.generators.db.FetchMappedObjectDBMethodGenerator
generateMethods inherited from class no.sikt.graphitron.generators.db.FetchDBMethodGenerator
createAliasDeclarations, createAliasDeclarations, createOrderFieldsBlock, createOrderFieldsDeclarationBlock, createSeekAndLimitBlock, createSelectConditions, createSelectJoins, createSelectJoins, formatJooqConditions, formatWhereContents, generateCorrelatedSubquery, generateForField, generateForField, generateForUnionField, generateHelperMethodName, generateNestedMethodName, generateSelectRow, getInitialKey, getInputConditions, getReturnType, getSelectCode, inferFieldNamingConvention, wrapInField, wrapInMultisetMethods inherited from class no.sikt.graphitron.generators.abstractions.DBMethodGenerator
getDefaultSpecBuilder, getDefaultSpecBuilderMethods inherited from class no.sikt.graphitron.generators.abstractions.AbstractSchemaMethodGenerator
createServiceDependency, declareAllServiceClasses, declareAllServiceClasses, declareAllServiceClassesInAliasSet, getDataFetcherWiring, getDependencyMap, getLocalObject, getLocalTable, getTypeResolverWiring
-
Constructor Details
-
ServiceResultFetchDBMethodGenerator
public ServiceResultFetchDBMethodGenerator(ObjectDefinition localObject, ProcessedSchema processedSchema)
-
-
Method Details
-
isRoot
protected boolean isRoot()- Overrides:
isRootin classFetchDBMethodGenerator
-
getHelperMethodCallForNestedField
protected no.sikt.graphitron.javapoet.CodeBlock getHelperMethodCallForNestedField(ObjectField field, FetchContext context) Description copied from class:FetchDBMethodGeneratorGenerates a helper method call for nested record type fields. This base implementation generates the root-level helper method call.- Overrides:
getHelperMethodCallForNestedFieldin classFetchDBMethodGenerator- Parameters:
field- The field to generate the helper method call forcontext- The fetch context (unused in base implementation)- Returns:
- CodeBlock containing the helper method call, or null to use inline generation
-
getSelectBlockForRecord
protected no.sikt.graphitron.javapoet.CodeBlock getSelectBlockForRecord(ObjectField target, no.sikt.graphitron.javapoet.CodeBlock selectRowBlock, boolean isReferenceResolverField, InputParser parser) Description copied from class:FetchMappedObjectDBMethodGeneratorDetermine the select block to use for record types. By default, delegates to a helper method unless the field is a reference resolver field (which uses a correlated subquery). Subclasses can override to always inline the select.- Overrides:
getSelectBlockForRecordin classFetchMappedObjectDBMethodGenerator
-
getSpecBuilder
protected no.sikt.graphitron.javapoet.MethodSpec.Builder getSpecBuilder(ObjectField referenceField, no.sikt.graphitron.javapoet.TypeName refTypeName, InputParser parser) Override to exclude input parameters from the DB method signature. Input arguments are passed to the service call, not to the DB query.- Overrides:
getSpecBuilderin classFetchDBMethodGenerator
-
generateAll
- Specified by:
generateAllin interfaceMethodGenerator- Overrides:
generateAllin classFetchMappedObjectDBMethodGenerator- Returns:
- List of complete javapoet
MethodSpecthat can be generated for this object.
-