@Component(value="blRelationshipOverridesUtil") public class RelationshipOverridesUtil extends Object
Common utility for database-backed inherited catalog relationship overrides. Most (if not all) of the queries for
this is used in very similar ways across anything that relates to a parent entity, which means that anything that implements
RelationshipOverridesExtensionHandler
will likely need to utilize this.
Only relevant when running with Broadleaf Multi Tenant enabled, kept here for other modules to utilize
Modifier and Type | Field and Description |
---|---|
protected javax.persistence.EntityManager |
em |
protected org.broadleafcommerce.common.dao.GenericEntityDao |
genericEntityDao |
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil |
transUtil |
Constructor and Description |
---|
RelationshipOverridesUtil() |
Modifier and Type | Method and Description |
---|---|
void |
appendRelationshipQueryWhereClause(StringBuilder sb,
Class<?> type,
Class<?> targetType,
String targetIdField,
String targetFieldName)
Append the where clause params for the relationship entity count and basic retrieval queries.
|
protected Map<Long,Set<Long>> |
buildUpOverriddenRelationshipCatalogs(javax.persistence.TypedQuery<Long> countQuery,
javax.persistence.Query catalogQuery)
Execute queries to retrieve the standard site overridden catalogs and build up the overrides map for a particular
relation type.
|
protected Long |
convertId(Object id)
In translations, the id comes back as a String while normal relationships come back as a Long.
|
Map<Long,Set<Long>> |
getRelationshipOverrideCatalogsForType(Class<?> relationType,
String targetFieldName,
Class<?> relationTargetType)
For the specified xref relation to target type, final all standard site catalogs that have an overridden version of the relation.
|
Map<Long,Set<Long>> |
getTranslationOverrideCatalogsForType(org.broadleafcommerce.common.i18n.domain.TranslatedEntity translationType)
Gets all of the places that translations have been overridden for particular products (really, their defaultSkus)
|
void |
mergeOverrides(Map<Long,Set<Long>> receivingOverrides,
Map<Long,Set<Long>> overridesToMerge)
Add a map of overrides to an overall collection of overrides
|
protected javax.persistence.EntityManager em
protected org.broadleafcommerce.common.util.StreamingTransactionCapableUtil transUtil
protected org.broadleafcommerce.common.dao.GenericEntityDao genericEntityDao
public void mergeOverrides(Map<Long,Set<Long>> receivingOverrides, Map<Long,Set<Long>> overridesToMerge)
receivingOverrides
- the overall overridesoverridesToMerge
- the subset of overridespublic Map<Long,Set<Long>> getTranslationOverrideCatalogsForType(org.broadleafcommerce.common.i18n.domain.TranslatedEntity translationType)
relationType
- translationProperty
- ClassNotFoundException
public Map<Long,Set<Long>> getRelationshipOverrideCatalogsForType(Class<?> relationType, String targetFieldName, Class<?> relationTargetType)
relationType
- the type of the xref entity (e.g. CategoryProductXrefImpl
)targetFieldName
- the field on the relationType holding the reference to the target (e.g. CategoryProductXrefImpl.product
)relationTargetType
- the type of the target field (e.g. ProductImpl
)public void appendRelationshipQueryWhereClause(StringBuilder sb, Class<?> type, Class<?> targetType, String targetIdField, String targetFieldName)
sb
- the stub of the count or retrieval querytype
- the relation typetargetType
- the type of the relation targettargetIdField
- the id field of the target typetargetFieldName
- the field in the relation entity pointing to targetprotected Map<Long,Set<Long>> buildUpOverriddenRelationshipCatalogs(javax.persistence.TypedQuery<Long> countQuery, javax.persistence.Query catalogQuery)
countQuery
- the count query to retrieve the overridden catalogscatalogQuery
- the query to retrieve the overridden catalogsCopyright © 2019. All rights reserved.