O
- as Organization typeU
- as SAASUser
for O typepublic abstract class TenantContextJPAQueryTransformer<O extends Organization,U extends SAASUser<O>> extends JPAQueryTransformer implements ContextConsumer<UserShell<U,?>>
Transformer
ensures all generic queries are made in context to the current Tenant.User#getOrganizations()
and User#getPrimaryOrganization()
VerifyShellAccessToTenantTransformer
,
CurrentTenantSupplier
,
MultiTenantRecord
,
Serialized FormexpectSingleResult, fieldMapping, query, queryIsNative, queryOptimizer, queryOptimizerEntityAlias
Constructor and Description |
---|
TenantContextJPAQueryTransformer() |
TenantContextJPAQueryTransformer(String query) |
Modifier and Type | Method and Description |
---|---|
String |
derivedQuery()
Opportunity to override core
JPAQueryTransformer.query string. |
protected String |
derivedQueryWhenNoContext()
Special
derivedQuery() version, when ContextConsumer.deriveContext() returns null (no context available) |
protected Collection<O> |
getAuthorizedUnits(U user)
Based on context or current user get the Units the current session/request has access to.
|
protected abstract String |
getTenantEntityName()
Which JPA entity is Tenant/Organization representing
|
String |
getTenantJoin()
If not null will add to the end of the query
AND <org=venue.owenerOrganization> OR {@code |
protected boolean |
isAuthorizedAccessToAllOrgs(U user) |
static void |
main(String... args) |
protected void |
overrideFinalQuery(String queryString,
javax.persistence.Query q)
Opportunity to override any thing in the final generated Query
Query
in the JPAQueryTransformer.transform(Object) process. |
protected void |
overrideFinalQueryWhenNoContext()
Special
overrideFinalQuery(String, Query) version, when ContextConsumer.deriveContext() returns null (no context available) |
void |
setTenantJoin(String tenantJoin)
If not null will add to the end of the query
AND <org=venue.owenerOrganization> OR {@code |
getFieldMapping, getPageInfo, getQuery, getQueryOptimizer, getQueryOptimizerEntityAlias, isExpectSingleResult, isParamAsSingleInput, isQueryIsNative, optimize, setExpectSingleResult, setFieldMapping, setPageInfo, setParamAsSingleInput, setQuery, setQueryIsNative, setQueryOptimizer, setQueryOptimizerEntityAlias, transform
getEntityManager, getEntityManagerProvider, setEntityManager, setEntityManagerProvider, updateContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
deriveContext
public TenantContextJPAQueryTransformer()
public TenantContextJPAQueryTransformer(String query)
protected abstract String getTenantEntityName()
protected Collection<O> getAuthorizedUnits(U user)
ThreadLocal
or some way to
tap into the session or request.protected void overrideFinalQuery(String queryString, javax.persistence.Query q)
Query
in the JPAQueryTransformer.transform(Object)
process.
overrideFinalQuery
in class JPAQueryTransformer
queryString
- as String (immutable, provided for reference purpose only)q
- as Queryalso, as these work together
,
overrideFinalQueryWhenNoContext()
public static void main(String... args)
public String derivedQuery()
derivedQuery
in class JPAQueryTransformer
also, as these work together
,
derivedQueryWhenNoContext()
protected String derivedQueryWhenNoContext()
derivedQuery()
version, when ContextConsumer.deriveContext()
returns null (no context available)protected void overrideFinalQueryWhenNoContext()
overrideFinalQuery(String, Query)
version, when ContextConsumer.deriveContext()
returns null (no context available)protected boolean isAuthorizedAccessToAllOrgs(U user)
public String getTenantJoin()
<org=venue.owenerOrganization>
OR {@code public void setTenantJoin(String tenantJoin)
<org=venue.owenerOrganization>
OR {@code Copyright © 2018. All rights reserved.