Class TemplatedExecutableStatementBuilder
- java.lang.Object
-
- net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
-
- net.shibboleth.idp.attribute.resolver.dc.rdbms.AbstractExecutableStatementBuilder
-
- net.shibboleth.idp.attribute.resolver.dc.rdbms.TemplatedExecutableStatementBuilder
-
- All Implemented Interfaces:
ExecutableSearchBuilder<ExecutableStatement>,Component,DestructableComponent,InitializableComponent
- Direct Known Subclasses:
V2CompatibleTemplatedExecutableStatementBuilder
public class TemplatedExecutableStatementBuilder extends AbstractExecutableStatementBuilder
AnExecutableSearchBuilderthat generates the SQL statement to be executed by evaluating aTemplateagainst the currently resolved attributes within aAttributeResolutionContext.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static classTemplatedExecutableStatementBuilder.EscapingReferenceInsertionEventHandlerEscapes SQL values added to the template context.
-
Field Summary
Fields Modifier and Type Field Description private org.apache.velocity.app.VelocityEngineengineVelocityEngine.private org.apache.velocity.app.event.ReferenceInsertionEventHandlereventHandlerEvent handler used for escaping.private org.slf4j.LoggerlogClass logger.private TemplatetemplateTemplate to be evaluated.private StringtemplateTextTemplate (as Text) to be evaluated.private booleanv2CompatibilityDo we need to make ourself V2 Compatible?
-
Constructor Summary
Constructors Constructor Description TemplatedExecutableStatementBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddExtraVelocityContext(org.apache.velocity.VelocityContext velocityContext, AttributeResolutionContext resolutionContext)Method to allow private additions to the velocity context.protected voiddoInitialize()org.apache.velocity.app.event.ReferenceInsertionEventHandlergetReferenceInsertionEventHandler()Gets theReferenceInsertionEventHandlerto be used.StringgetSQLQuery(AttributeResolutionContext resolutionContext, Map<String,List<IdPAttributeValue>> dependencyAttributes)Apply the context to the template.TemplategetTemplate()Gets the template to be evaluated.StringgetTemplateText()Gets the template text to be evaluated.org.apache.velocity.app.VelocityEnginegetVelocityEngine()Gets theVelocityEngineto be used.booleanisV2Compatibility()Are we in V2 Compatibility mode?protected Stringmerge(org.apache.velocity.VelocityContext context)InvokesTemplate.merge(org.apache.velocity.context.Context)on the supplied context.voidsetReferenceInsertionEventHandler(org.apache.velocity.app.event.ReferenceInsertionEventHandler handler)Sets theReferenceInsertionEventHandlerto be used.voidsetTemplateText(String velocityTemplate)Sets the template to be evaluated.voidsetV2Compatibility(boolean compat)What is out V2 Compatibility mode.voidsetVelocityEngine(org.apache.velocity.app.VelocityEngine velocityEngine)Sets theVelocityEngineto be used.-
Methods inherited from class net.shibboleth.idp.attribute.resolver.dc.rdbms.AbstractExecutableStatementBuilder
build, getQueryTimeout, setQueryTimeout
-
Methods inherited from class net.shibboleth.utilities.java.support.component.AbstractInitializableComponent
destroy, doDestroy, initialize, isDestroyed, isInitialized
-
-
-
-
Field Detail
-
log
private final org.slf4j.Logger log
Class logger.
-
template
private Template template
Template to be evaluated.
-
templateText
private String templateText
Template (as Text) to be evaluated.
-
engine
private org.apache.velocity.app.VelocityEngine engine
VelocityEngine.
-
eventHandler
private org.apache.velocity.app.event.ReferenceInsertionEventHandler eventHandler
Event handler used for escaping.
-
v2Compatibility
private boolean v2Compatibility
Do we need to make ourself V2 Compatible?
-
-
Method Detail
-
getTemplate
@NonnullAfterInit public Template getTemplate()
Gets the template to be evaluated.- Returns:
- the template
-
getTemplateText
@NonnullAfterInit public String getTemplateText()
Gets the template text to be evaluated.- Returns:
- the template text
-
setTemplateText
public void setTemplateText(@Nullable String velocityTemplate)Sets the template to be evaluated.- Parameters:
velocityTemplate- template to be evaluated
-
getVelocityEngine
@Nullable @NonnullAfterInit public org.apache.velocity.app.VelocityEngine getVelocityEngine()
Gets theVelocityEngineto be used.- Returns:
- the template
-
setVelocityEngine
public void setVelocityEngine(@Nonnull org.apache.velocity.app.VelocityEngine velocityEngine)Sets theVelocityEngineto be used.- Parameters:
velocityEngine- engine to be used
-
getReferenceInsertionEventHandler
@Nullable public org.apache.velocity.app.event.ReferenceInsertionEventHandler getReferenceInsertionEventHandler()
Gets theReferenceInsertionEventHandlerto be used.- Returns:
- the reference insertion event handler
-
setReferenceInsertionEventHandler
public void setReferenceInsertionEventHandler(@Nullable org.apache.velocity.app.event.ReferenceInsertionEventHandler handler)Sets theReferenceInsertionEventHandlerto be used.- Parameters:
handler- reference insertion event handler to be used
-
isV2Compatibility
public boolean isV2Compatibility()
Are we in V2 Compatibility mode?- Returns:
- Returns the v2Compat.
-
setV2Compatibility
public void setV2Compatibility(boolean compat)
What is out V2 Compatibility mode.- Parameters:
compat- The mode to set.
-
merge
protected String merge(@Nonnull org.apache.velocity.VelocityContext context)
InvokesTemplate.merge(org.apache.velocity.context.Context)on the supplied context.- Parameters:
context- to merge- Returns:
- result of the merge operation
-
getSQLQuery
public final String getSQLQuery(@Nonnull AttributeResolutionContext resolutionContext, @Nonnull Map<String,List<IdPAttributeValue>> dependencyAttributes) throws ResolutionException
Apply the context to the template. Method to return the query SQL.- Specified by:
getSQLQueryin classAbstractExecutableStatementBuilder- Parameters:
resolutionContext- the context of the resolutiondependencyAttributes- made available to the executable search- Returns:
- the SQL string
- Throws:
ResolutionException- if we get an error building the exception.
-
addExtraVelocityContext
protected void addExtraVelocityContext(@Nonnull org.apache.velocity.VelocityContext velocityContext, @Nonnull AttributeResolutionContext resolutionContext)Method to allow private additions to the velocity context.- Parameters:
velocityContext- where to add the informationresolutionContext- current resolution context
-
doInitialize
protected void doInitialize() throws ComponentInitializationException- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
-