Package org.cyclos.db
Class AbstractDatabasePopulator
- java.lang.Object
-
- org.cyclos.db.AbstractDatabasePopulator
-
- All Implemented Interfaces:
DatabasePopulator,CustomBean
- Direct Known Subclasses:
BasicPopulator
public abstract class AbstractDatabasePopulator extends Object implements DatabasePopulator
Contains the infrastructure forDatabasePopulators
-
-
Field Summary
Fields Modifier and Type Field Description protected ApplicationContextapplicationContextprotected ConfigurationHandlerconfigurationHandlerprotected ConversionHandlerconversionHandlerprotected CyclosPropertiescyclosPropertiesprotected EntityManagerHandlerentityManagerHandlerprotected EntityLogServiceLocalentityServiceLocalServiceprotected InvokerHandlerinvokerHandlerprotected ProductsHandlerproductsHandlerprotected Randomrandomprotected RawEntityManagerHandlerrawEntityManagerHandlerprotected SessionHandlersessionHandler
-
Constructor Summary
Constructors Constructor Description AbstractDatabasePopulator()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected <CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>>
Map<String,PV>createPossibleValues(CF field, Class<PV> possibleValueType, String... possibleValues)Creates possible values for the given custom fieldprotected List<UserProductNotificationDTO>createProductNotifications(List<UserNotificationType> notificationTypes)Creates a list of products x notification types (setting enabled and by e-mail by default)protected List<UserProductNotificationDTO>createProductNotifications(UserNotificationType... notificationTypes)Creates a list of products x notification types (setting enabled and by e-mail by default)protected <T extends SimpleEntity>
Tfind(Class<T> type, Long id)Finds an entity by idprotected DBQuery<?>from(com.querydsl.core.types.dsl.EntityPathBase<?>... from)protected IntegerRangeDTOintRange(int min, int max)protected <T> List<T>listAll(com.querydsl.core.types.dsl.EntityPathBase<T> alias)Returns a list with all entities of the given aliasprotected voidpersist(IEntity entity)protected intrandom(IntegerRange range)Returns a random integer within the rangeprotected <E extends BaseEntity,DTO extends EntityDTO>
Esave(CRUDService<DTO,?,?> service, DTO dto)Saves a DTO, using the same service to find the entity by idprotected voidsetDashboardActions(ProductDTO product, DashboardAction... actions)Creates a list of dashboard actions (setting both enabled and by default)protected <CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>>
voidsetRandomValue(CustomFieldValue<CF,C,PV,?> fieldValue)Returns a random value acceptable for the given field-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.cyclos.db.DatabasePopulator
getDisplayName, populate
-
-
-
-
Field Detail
-
applicationContext
@Autowired protected ApplicationContext applicationContext
-
cyclosProperties
@Autowired protected CyclosProperties cyclosProperties
-
entityManagerHandler
@Autowired protected EntityManagerHandler entityManagerHandler
-
rawEntityManagerHandler
@Autowired protected RawEntityManagerHandler rawEntityManagerHandler
-
productsHandler
@Autowired protected ProductsHandler productsHandler
-
configurationHandler
@Autowired protected ConfigurationHandler configurationHandler
-
conversionHandler
@Autowired protected ConversionHandler conversionHandler
-
invokerHandler
@Autowired protected InvokerHandler invokerHandler
-
sessionHandler
@Autowired protected SessionHandler sessionHandler
-
entityServiceLocalService
@Autowired protected EntityLogServiceLocal entityServiceLocalService
-
random
protected Random random
-
-
Method Detail
-
createPossibleValues
protected <CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>> Map<String,PV> createPossibleValues(CF field, Class<PV> possibleValueType, String... possibleValues)
Creates possible values for the given custom field
-
createProductNotifications
protected List<UserProductNotificationDTO> createProductNotifications(List<UserNotificationType> notificationTypes)
Creates a list of products x notification types (setting enabled and by e-mail by default)
-
createProductNotifications
protected List<UserProductNotificationDTO> createProductNotifications(UserNotificationType... notificationTypes)
Creates a list of products x notification types (setting enabled and by e-mail by default)
-
find
protected <T extends SimpleEntity> T find(Class<T> type, Long id)
Finds an entity by id
-
from
protected DBQuery<?> from(com.querydsl.core.types.dsl.EntityPathBase<?>... from)
-
intRange
protected IntegerRangeDTO intRange(int min, int max)
-
listAll
protected <T> List<T> listAll(com.querydsl.core.types.dsl.EntityPathBase<T> alias)
Returns a list with all entities of the given alias
-
persist
protected void persist(IEntity entity)
-
random
protected int random(IntegerRange range)
Returns a random integer within the range
-
save
protected <E extends BaseEntity,DTO extends EntityDTO> E save(CRUDService<DTO,?,?> service, DTO dto)
Saves a DTO, using the same service to find the entity by id
-
setDashboardActions
protected void setDashboardActions(ProductDTO product, DashboardAction... actions)
Creates a list of dashboard actions (setting both enabled and by default)
-
setRandomValue
protected <CF extends CustomField<CF,C,PV>,C extends CustomFieldPossibleValueCategory<CF,C,PV>,PV extends CustomFieldPossibleValue<CF,C,PV>> void setRandomValue(CustomFieldValue<CF,C,PV,?> fieldValue)
Returns a random value acceptable for the given field
-
-