Class CollectingEntityListener
- All Implemented Interfaces:
ContextListener
,EntityFacadeListener
,CommitListener
,EventListener
- Direct Known Subclasses:
AbsenceReportAllottedEntityListener
,AbstractContactCreateListener
,AccountEntityListener
,ActiveVatRateEntityListener
,AddressDebitorInformationEntityListener
,AliasNormalizerEntityListener
,ArchivedUserEntityListener
,ArticlePriceSortingEntityListener
,AvailabilityCalendarFieldsListener
,BatchJobEntityListener
,BillingPositionCheckEntityListener
,BillingPositionEntityCheckEntityListener
,BirthdateSortingEntityListener
,CalculateActualPointsEntityListener
,CalculateAmountEntityListener
,CalculateMaxPointsEntityListener
,CalculateNumberOfReservationsEntityListener
,CalendarEventLabelUpdateListener
,CampaignActualValuesEntityListener
,CampaignEffortEntityListener
,CaseBillingPositionEntityListener
,ChildFunctionListener
,ClearGeoLocationListener
,ClientCacheInvalidationListener
,ContactAddressEntityListener
,ContactAllUsersListener
,ContractCreateEntityListener
,ContractDateDeleteEntityListener
,ContractValidityDateEntityListener
,CopyBillingPositionEntityListener
,CopyDocumentsToEntityDocsListener
,CopyEducationalSchedulesToEventListener
,CopyPathEntityListener
,CorrespondenceContactUpdateEntityListener
,CostCenterEntityListener
,CountEntitiesListener
,CourseOfStudyEntityListener
,CreateCalendarExportListener
,CreateEvaluationAnswersEntityListener
,CreateOnlinepaymentOrderListener
,CreditRatingEntityListener
,CustomerContractBillingPositionEntityListener
,DeactivateEntityListener
,DebitorCreationEntityListener
,DefaultReportRecipientFlagEntityListener
,DefaultUserInvoicedEntityListener
,DeleteMovementEntityListener
,DeleteMovementWithArticleEntityListener
,DonationContactEntityListener
,EffortFieldUpdateEntityListener
,EffortProjectionEntityListener
,EffortTimereportEntityListener
,EmailArchiveTypeEntityListener
,EnsureNoVoucherForFinancialYearEntityListener
,EntityCalendarEventListener
,EntityDocumentsPropagateRelationEntityListener
,EntityHistoryDeletionEntityListener
,EntityTemplateCreateEntityListener
,EvaluationEntityListener
,EventCancellationEntityListener
,EventCostsCalculatorEntityListener
,EventIsTemplateEntityListener
,EventPeriodEntityListener
,EventPropagationEntityListener
,EventRequirementEntityListener
,EventSeminarRelationEntityListener
,EventStatusEntityListener
,ExamTemplateNumberingListener
,ExpenseCalculateCostEntityListener
,FlipUserSalutationEntityListener
,FunctionMutationEntityListener
,GenerateRegistrationUuidEntityListener
,GenericCalendarEventListener
,InitNodeRightsEntityListener
,InputEntityListener
,InvalidateCmsTemplateCacheListener
,LecturerBookingPropagationEntityListener
,LecturerBookingTotalLessonsEntityListener
,LecturerBookingUserUpdateListener
,LicenceBillingPositionEntityListener
,LicenceEntityListener
,LinkedAnswerOptionEntityListener
,LinkedQuestionEntityListener
,MembershipBillingPositionEntityListener
,MembershipUserAnswerEntityListener
,MinimalPresenceDeleteEntityListener
,MovementArticleEntityListener
,MovementBillingPositionEntityListener
,OfftimeEventMappingEntityListener
,OneStandardValueEntityListener
,OrderBillPrintedCheckEntityListener
,OrderBillPrintedEntityListener
,OrderDeletionEntityListener
,OrderOrderRateEntityListener
,OrderPositionDiscountEntityListener
,OrderPositionPriceChangeEntityListener
,OrderPositionSortingEntityListener
,OrderPriceRecalculationEntityListener
,OrderRateFeeEntityListener
,OrderTextsEntityListener
,PrepaymentStatusEntityListener
,PrepaymentVoucherEntityListener
,PrincipalEntityListener
,PrincipalSessionEntityListener
,PromotionCodeEntityListener
,PromotionDataRegistrationListener
,QualificationRegistrationInformationListener
,QuestionnaireFixationEntityListener
,RefreshOrderTotalsEntityListener
,RegistrationEntityListener
,RegistrationPropagationEntityListener
,RegistrationRequirementEntityListener
,RegistrationSetEntityListener
,RegistrationStatusRelevantForGradeEntityListener
,ReplaceBinaryEntityListener
,RequirementAccomplishmentListener
,RequirementCheckDateEntityListener
,RequirementPackageEntityListener
,RequirementRuleCheckEntityListener
,ReservationCountEntityListener
,ReservationPropagationEntityListener
,ReservationRegistrationCountEntityListener
,ReservationRegistrationEntityListener
,ResetConflictsStatusListener
,ResourceUpdateTimestampListener
,SchoolingRegistrationEntityListener
,ScriptEntityFacadeListener
,SeminarPeriodCountEntityListener
,SetAddressFieldsEntityListener
,SetBusinessUnitListener
,SetDefaultSalaryOnLecturerBookingEntityListener
,SetEventArchivedEntityListener
,SetEventPublicationDateEntityListener
,SetInputDataRegistrationListener
,SetMembershipTypeRelationsEntityListener
,SetMergedOutputJobsStatusEntityListener
,SetStatusDateEntityListener
,SetUnbalancedPrepaymentFlagEntityListener
,SmsContactCreatorEntityListener
,SummarizeMaxPointsEntityListener
,SurveyIntrusionEntityListener
,SurveyUserIntrusionEntityListener
,TermsConditionConfirmationSourceListener
,ThresholdValueEntityListener
,TimereportRecordEntityListener
,TimereportSchemeDayEntityListener
,TopicEntityListener
,TransferCantonFromUserToSchoolingEntityListener
,UniqueOrderTemplateListener
,UpdateAddressBlockEntityListener
,UpdateContingentOnMovementEntityListener
,UpdateEventConnectionTypeListener
,UpdateHierarchyListener
,UpdateLoginEntityListener
,UpdateOpenBalanceDueEntityListener
,UpdatePagePositionEntityListener
,UpdateReferencesListener
,UpdateSectionPositionListener
,UpdateUrlIndexListener
,UpdateWidgetRecordListener
,VoucherChangedEntityListener
,VoucherStornoDebitorEntityListener
,WidgetConfigUpdateListener
,WidgetDomainSecretListener
,ZipFieldsUpdateEntityListener
EntityFacadeListener that collects facade events up until the current transaction is about
to be committed. Every EntityFacadeEvent
that comes in after the berfore-commit is
discarded. This especially applies to all EntityFacadeEvent
s that are generated due to
this listener.
Subclasses can listen for the before-commit event by implementing the onBeforeCommit(Transaction)
method. At this point the entities that have been created and/or updated are available via
getAffectedEntities()
(and some filtering methods like getCreatedEntities()
).
Additional data to each entity can be retrieved
via getOldValues(Entity)
and getRelationChanges(Entity)
Note, this listener must be registered with the @ThreadScope
annotation and the
@Listener(filter = "Resource")
annotation to define the filter.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Predicate to filter entities by entity model name.static class
Predicate to filter entities which have at least one of the given fields touched.static class
Predicate to filter entities which have a certain relation touched. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
afterCommit
(Context context) Notifies about the point where the transaction has been fully committed.void
Notifies about the point where the transaction is about to be committed.final void
contextDestroying
(ContextEvent event) final void
entityChanging
(EntityChangedEvent event) Fired when any changes are made to an entity.final void
entityCreating
(EntityFacadeEvent event) Fired when an entity is being created.final void
entityDeleting
(EntityFacadeEvent event) Fired when an entity is being deleted.entityModel
(String entityModelName) final void
Fired when a relation of an entity has been changed.fieldTouched
(String... fieldNames) fieldTouched
(Collection<String> fieldNames) getAddedRelationChangesFor
(Entity e, String relationName) Get all entities that have been created or updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.getAffectedEntities
(Predicate<Entity> predicate) Get all entities that have been created or updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.Get all entities that have been affected in any way (created, updated or deleted) during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.getAllAffectedEntities
(Predicate<Entity> predicate) Get all entities that have been affected in any way (created, updated or deleted) during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.Get all entities that have been created during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.getCreatedEntities
(Predicate<Entity> predicate) Get all entities that have been created during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.Get all entities that have been created or updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.getDeletedEntities
(Predicate<Entity> predicate) Get all entities that have been deleted during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.protected Object
getRelationChangesFor
(Entity e, String... relationNames) getRelationChangesFor
(Entity e, Collection<String> relationNames) getRemovedRelationChangesFor
(Entity e, String relationName) Get all entities that have been updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.getUpdatedEntities
(Predicate<Entity> predicate) Get the updated entities.protected boolean
isValidTx
(EntityFacadeEvent event) abstract void
protected void
protected void
protected void
protected void
relationTouched
(String... relationNames) relationTouched
(Collection<String> relationNames) void
void
withAffectedEntities
(Consumer<Entity> consumer) Do something with the entities that have been created or updated during the transactionvoid
withAffectedEntities
(Consumer<Entity> consumer, Predicate<Entity> predicate) Do something with the entities that have been created or updated during the transactionvoid
withAllAffectedEntities
(Consumer<Entity> consumer) Do something with the entities that have been affected in any way (created, updated or deleted) during the transactionvoid
withAllAffectedEntities
(Consumer<Entity> consumer, Predicate<Entity> predicate) Do something with the entities that have been affected in any way (created, updated or deleted) during the transactionvoid
withCreatedEntities
(Consumer<Entity> consumer) Do something with the entities that have been created during the transactionvoid
withCreatedEntities
(Consumer<Entity> consumer, Predicate<Entity> predicate) Do something with the entities that have been created during the transactionvoid
withDeletedEntities
(Consumer<Entity> consumer) Do something with the entities that have been updated during the transactionvoid
withDeletedEntities
(Consumer<Entity> consumer, Predicate<Entity> predicate) Do something with the entities that have been deleted during the transactionvoid
withUpdatedEntities
(Consumer<Entity> consumer) Do something with the entities that have been updated during the transactionvoid
withUpdatedEntities
(Consumer<Entity> consumer, Predicate<Entity> predicate) Do something with the entities that have been updated during the transactionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface ch.tocco.nice2.persist.core.api.util.CommitListener
afterFlush, priority
Methods inherited from interface ch.tocco.nice2.persist.core.api.entity.events.EntityFacadeListener
entityReceivedValues, handleSessionOnlyEntity
-
Constructor Details
-
CollectingEntityListener
public CollectingEntityListener()
-
-
Method Details
-
beforeCommit
Description copied from interface:CommitListener
Notifies about the point where the transaction is about to be committed.
This allows further modification of involved entities.
- Specified by:
beforeCommit
in interfaceCommitListener
- Parameters:
tx
- the transaction in question
-
onBeforeCommit
-
getKey
-
afterCommit
Description copied from interface:CommitListener
Notifies about the point where the transaction has been fully committed.
This allows post processing of the entities involved in the previous commit.
- Specified by:
afterCommit
in interfaceCommitListener
-
withAllAffectedEntities
Do something with the entities that have been affected in any way (created, updated or deleted) during the transaction- Parameters:
consumer
- The consumer to call for each entity
-
getAllAffectedEntities
Get all entities that have been affected in any way (created, updated or deleted) during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- all entities that have been affected in any way (created, updated or deleted) during the transaction
- See Also:
-
withAllAffectedEntities
Do something with the entities that have been affected in any way (created, updated or deleted) during the transaction- Parameters:
consumer
- The consumer to call for each entitypredicate
- The predicate to filter the updated entities by
-
getAllAffectedEntities
Get all entities that have been affected in any way (created, updated or deleted) during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- all entities that have been affected in any way (created, updated or deleted) during the transaction
- See Also:
-
withAffectedEntities
Do something with the entities that have been created or updated during the transaction- Parameters:
consumer
- The consumer to call for each entity
-
getAffectedEntities
Get all entities that have been created or updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been created or updated during the transaction
- See Also:
-
withAffectedEntities
Do something with the entities that have been created or updated during the transaction- Parameters:
consumer
- The consumer to call for each entitypredicate
- The predicate to filter the updated entities by
-
getAffectedEntities
Get all entities that have been created or updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been created or updated during the transaction
- See Also:
-
withCreatedEntities
Do something with the entities that have been created during the transaction- Parameters:
consumer
- The consumer to call for each entity
-
getCreatedEntities
Get all entities that have been created during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been created during the transaction
- See Also:
-
withCreatedEntities
Do something with the entities that have been created during the transaction- Parameters:
consumer
- The consumer to call for each entitypredicate
- The predicate to filter the updated entities by
-
getCreatedEntities
Get all entities that have been created during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been created during the transaction
- See Also:
-
withUpdatedEntities
Do something with the entities that have been updated during the transaction- Parameters:
consumer
- The consumer to call for each entity
-
getUpdatedEntities
Get all entities that have been updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been updated during the transaction
- See Also:
-
withUpdatedEntities
Do something with the entities that have been updated during the transaction- Parameters:
consumer
- The consumer to call for each entitypredicate
- The predicate to filter the updated entities by
-
getUpdatedEntities
-
withDeletedEntities
Do something with the entities that have been updated during the transaction- Parameters:
consumer
- The consumer to call for each entity
-
getDeletedEntities
Get all entities that have been created or updated during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been deleted or updated during the transaction
- See Also:
-
withDeletedEntities
Do something with the entities that have been deleted during the transaction- Parameters:
consumer
- The consumer to call for each entitypredicate
- The predicate to filter the updated entities by
-
getDeletedEntities
Get all entities that have been deleted during the transaction Caution: for performance and memory consumption reasons, the corresponding `with...(Consumer, ...)` should be used whenever possible.- Returns:
- entities that have been deleted during the transaction
- See Also:
-
getOldValues
-
getRelationChanges
-
getAddedRelationChanges
-
getRemovedRelationChanges
-
getRelationChangesFor
-
getRelationChangesFor
public List<EntityRelationChangedEvent> getRelationChangesFor(Entity e, Collection<String> relationNames) -
getAddedRelationChangesFor
-
getRemovedRelationChangesFor
-
getAllRelationChanges
-
entityCreating
Description copied from interface:EntityFacadeListener
Fired when an entity is being created.- Specified by:
entityCreating
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
onEntityCreating
-
entityDeleting
Description copied from interface:EntityFacadeListener
Fired when an entity is being deleted.- Specified by:
entityDeleting
in interfaceEntityFacadeListener
- Parameters:
event
- The event Object
-
onEntityDeleting
-
isValidTx
-
entityChanging
Description copied from interface:EntityFacadeListener
Fired when any changes are made to an entity.- Specified by:
entityChanging
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
onEntityChanging
-
entityRelationChanging
Description copied from interface:EntityFacadeListener
Fired when a relation of an entity has been changed.- Specified by:
entityRelationChanging
in interfaceEntityFacadeListener
- Parameters:
event
- The event object.
-
onEntityRelationChanging
-
contextDestroying
- Specified by:
contextDestroying
in interfaceContextListener
-
transactionStarted
- Specified by:
transactionStarted
in interfaceContextListener
-
entityModel
-
fieldTouched
-
fieldTouched
public static CollectingEntityListener.FieldTouchedPredicate fieldTouched(Collection<String> fieldNames) -
relationTouched
public static CollectingEntityListener.RelationTouchedPredicate relationTouched(String... relationNames) -
relationTouched
public static CollectingEntityListener.RelationTouchedPredicate relationTouched(Collection<String> relationNames)
-