Class DefaultCharacteristicService<P extends Characteristic>
java.lang.Object
com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P>
com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
com.broadleafcommerce.catalog.service.product.characteristic.DefaultCharacteristicService<P>
- All Implemented Interfaces:
CharacteristicService<P>,com.broadleafcommerce.data.tracking.core.service.CrudEntityService<P>,com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService<P>
public class DefaultCharacteristicService<P extends Characteristic>
extends com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService<P>
implements CharacteristicService<P>
-
Constructor Summary
ConstructorsConstructorDescriptionDefaultCharacteristicService(CharacteristicRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CharacteristicValidator characteristicValidator) -
Method Summary
Modifier and TypeMethodDescriptionprotected CharacteristicValuebuildBooleanCharacteristicValue(int displayOrder, String label, boolean value) Builds aCharacteristicValueof typeBoolean.protected booleancharacteristicValueMatchesBoolean(List<CharacteristicValue> characteristicValues, boolean toMatch) Checks if the passed incharacteristic valuesall match the expected boolean value.voidprotected CharacteristicValidatorprotected StringgetMessage(@NonNull String message, @NonNull String defaultMessage, Object... args) Retrieves a message from a message source.protected org.springframework.context.MessageSourceprotected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node>protected CharacteristicRepository<com.broadleafcommerce.data.tracking.core.Trackable>protected com.broadleafcommerce.common.extension.TypeFactoryreadAllByIdIn(@NonNull Iterable<String> ids, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Reads all of the characteristics with matchingids.org.springframework.data.domain.Page<P>readAllByNameLike(String name, cz.jirutka.rsql.parser.ast.Node filters, org.springframework.data.domain.Pageable page, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Read all characteristics filtered by name.voidsetBooleanCharacteristicDefaultValuesIfNeeded(Characteristic characteristic) Sets the defaultcharacteristic valuesfor a configurable booleanCharacteristic.voidsetMessageSource(org.springframework.context.MessageSource messageSource) Methods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseRsqlCrudEntityService
getRsqlHelper, readAll, readAll, readAll, readAllMethods inherited from class com.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService
convertFromPersistentDomain, convertToPersistentDomain, create, createAll, createAllAllowingPartialSuccess, getHelper, getSortPositionStrategy, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, setSortPositionStrategy, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.CrudEntityService
create, createAll, createAllAllowingPartialSuccess, readAll, readAll, readAll, readAllByContextId, readByContextId, replace, replaceAll, replaceAllAllowingPartialSuccess, update, updateAll, updateAllAllowingPartialSuccess, updateSortMethods inherited from interface com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityService
readAll, readAll, readAll, readAll
-
Constructor Details
-
DefaultCharacteristicService
public DefaultCharacteristicService(CharacteristicRepository<com.broadleafcommerce.data.tracking.core.Trackable> repository, com.broadleafcommerce.data.tracking.core.service.RsqlCrudEntityHelper helper, com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> parser, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CharacteristicValidator characteristicValidator)
-
-
Method Details
-
readAllByNameLike
public org.springframework.data.domain.Page<P> readAllByNameLike(@Nullable String name, @Nullable cz.jirutka.rsql.parser.ast.Node filters, @Nullable org.springframework.data.domain.Pageable page, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CharacteristicServiceRead all characteristics filtered by name.- Specified by:
readAllByNameLikein interfaceCharacteristicService<P extends Characteristic>- Parameters:
name- The name to filter byfilters- additional filters to apply in the query. Should beEmptyNodeif no additional filters should be applied.page- the requested page of results from the databasecontextInfo- Request context information around sandbox and multitenant state- Returns:
- all business types filtered by name.
-
readAllByIdIn
public List<P> readAllByIdIn(@NonNull @NonNull Iterable<String> ids, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:CharacteristicServiceReads all of the characteristics with matchingids.- Specified by:
readAllByIdInin interfaceCharacteristicService<P extends Characteristic>- Parameters:
ids- The ids to matchcontextInfo- Request context information around sandbox and multitenant state- Returns:
- All of the characteristics with matching
ids.
-
getRepositoryDomain
- Specified by:
getRepositoryDomainin interfaceCharacteristicService<P extends Characteristic>
-
delete
public void delete(@NonNull String id, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo context) - Specified by:
deletein interfacecom.broadleafcommerce.data.tracking.core.service.CrudEntityService<P extends Characteristic>- Overrides:
deletein classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Characteristic>
-
setBooleanCharacteristicDefaultValuesIfNeeded
Description copied from interface:CharacteristicServiceSets the defaultcharacteristic valuesfor a configurable booleanCharacteristic. These are only set if the characteristic is newly created or has not been updated to have the true & false values set before.This change comes with the implementation that configurable boolean characteristics, when applied onto a
Productvia the appliedBusinessType, are added onto the Product as aCart Item AttributeProductOptionand allow the user to configure the boolean choice labels.- Specified by:
setBooleanCharacteristicDefaultValuesIfNeededin interfaceCharacteristicService<P extends Characteristic>- Parameters:
characteristic- The characteristic to check and update
-
characteristicValueMatchesBoolean
protected boolean characteristicValueMatchesBoolean(List<CharacteristicValue> characteristicValues, boolean toMatch) Checks if the passed incharacteristic valuesall match the expected boolean value.- Parameters:
characteristicValues- the characteristic values to checktoMatch- the expected boolean value to check for- Returns:
- whether the characteristic values all match the expected boolean value
- Since:
- Catalog Service 2.3.0, Release Train 2.3.0
-
buildBooleanCharacteristicValue
protected CharacteristicValue buildBooleanCharacteristicValue(int displayOrder, String label, boolean value) Builds aCharacteristicValueof typeBoolean.- Parameters:
displayOrder- the display order for this characteristic valuelabel- the label for this characteristic valuevalue- the characteristic value's value- Returns:
- the built
CharacteristicValueof typeBoolean - Since:
- Catalog Service 2.3.0, Release Train 2.3.0
-
getMessage
protected String getMessage(@NonNull @NonNull String message, @NonNull @NonNull String defaultMessage, @Nullable Object... args) Retrieves a message from a message source.- Parameters:
message- key of the message to retrievedefaultMessage- default message to display if message not found by keyargs- any arguments to supply to the message- Returns:
- the message from the message source
- Since:
- Catalog Service 2.3.0, Release Train 2.3.0
-
getRepository
protected CharacteristicRepository<com.broadleafcommerce.data.tracking.core.Trackable> getRepository()- Overrides:
getRepositoryin classcom.broadleafcommerce.data.tracking.core.service.BaseCrudEntityService<P extends Characteristic>
-
getParser
protected com.broadleafcommerce.data.tracking.core.filtering.fetch.FilterParser<cz.jirutka.rsql.parser.ast.Node> getParser() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getCharacteristicValidator
-
setMessageSource
@Autowired public void setMessageSource(org.springframework.context.MessageSource messageSource) -
getMessageSource
protected org.springframework.context.MessageSource getMessageSource()
-