public override object Invoke(params object [] arguments) { Net.Vpc.Upa.Callbacks.UpdateEvent ev = (Net.Vpc.Upa.Callbacks.UpdateEvent)arguments[0]; foreach (object id in ResolveIdList(ev, ev.GetFilterExpression())) { Net.Vpc.Upa.Record updatesRecord = ev.GetUpdatesRecord().Copy(); ev.GetEntity().GetBuilder().SetObjectId(updatesRecord, id); Net.Vpc.Upa.Callbacks.UpdateObjectEvent oe = new Net.Vpc.Upa.Callbacks.UpdateObjectEvent(id, updatesRecord, ev.GetFilterExpression(), ev.GetContext(), GetPhase()); InvokeSingle(oe); } return(null); }
public override bool AcceptUpdateTableOlderValuesHelper(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { if (relationFilter == null) { relationFilter = Net.Vpc.Upa.Filters.Fields.Regular().And(Net.Vpc.Upa.Filters.Fields.ByList(relation.GetSourceRole().GetFields())); } Net.Vpc.Upa.Entity entityManager = @event.GetEntity(); foreach (string updatedField in @event.GetUpdatesRecord().KeySet()) { if (relationFilter.Accept(entityManager.GetField(updatedField))) { return(true); } } return(false); }
public override bool AcceptUpdateTableHelper(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Filters.FieldFilter conditionFields = entityDetailFormulaUpdaterInterceptor.GetConditionFields(); if (conditionFields == null) { return(true); } Net.Vpc.Upa.Entity entityManager = @event.GetEntity(); foreach (string updatedField in @event.GetUpdatesRecord().KeySet()) { if (conditionFields.Accept(entityManager.GetField(updatedField))) { return(true); } } return(false); }
public override void OnPreUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext(); System.Collections.Generic.IList <Net.Vpc.Upa.Field> updateTreeFields = GetUpdateTreeFields(); Net.Vpc.Upa.Record updates = @event.GetUpdatesRecord(); if (!updates.IsSet(updateTreeFields[0].GetName())) { return; } object val = updates.GetObject <T>(updateTreeFields[0].GetName()); if (val is Net.Vpc.Upa.Expressions.Literal) { val = ((Net.Vpc.Upa.Expressions.Literal)val).GetValue(); } else if (val is Net.Vpc.Upa.Expressions.Expression) { // Log.bug("1232123"); return; } if (val != null) { object parentId = relation.ExtractId(updates); if (parentId != null) { Net.Vpc.Upa.Entity entity = @event.GetEntity(); string k = "recurse"; if (!executionContext.IsSet(k)) { System.Collections.Generic.IList <object> idList = entity.CreateQueryBuilder().ByExpression(@event.GetFilterExpression()).OrderBy(entity.GetUpdateFormulasOrder()).GetIdList <K>(); executionContext.SetObject(k, idList); } System.Collections.Generic.IList <object> r = (System.Collections.Generic.IList <object>)executionContext.GetObject <T>("recurse"); foreach (object aR in r) { if (support.IsEqualOrIsParent(aR, parentId)) { throw new Net.Vpc.Upa.Exceptions.UPAException("RedundancyProblem"); } } } } }
public override sealed void OnUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { // validate old references Net.Vpc.Upa.Persistence.EntityExecutionContext executioncontext = @event.GetContext(); string name = @event.GetTrigger().GetName(); System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> collection = executioncontext.GetObject <T>(name + ":toUpdate"); if (collection == null) { return; } executioncontext.Remove(name + ":toUpdate"); Net.Vpc.Upa.Expressions.IdCollectionExpression inColl = null; if (!(collection.Count == 0)) { inColl = CreateInCollection(@event.GetEntity(), collection); AfterUpdateHelper(@event, inColl); } // validate old references if (AcceptUpdateTableOlderValuesHelper(@event)) { Net.Vpc.Upa.Expressions.Expression newUpdates = null; if (inColl != null) { Net.Vpc.Upa.Expressions.Expression translated = TranslateExpression(@event.GetFilterExpression()); if (translated != null) { newUpdates = new Net.Vpc.Upa.Expressions.And(new Net.Vpc.Upa.Expressions.Not(inColl), translated); } else { newUpdates = new Net.Vpc.Upa.Expressions.Not(inColl); } } else { newUpdates = TranslateExpression(@event.GetFilterExpression()); } AfterUpdateHelper(@event, newUpdates); } }
public override bool AcceptUpdateTableHelper(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Filters.FieldFilter conditionFields = entityTargetFormulaUpdaterInterceptor.GetConditionFields(); if (conditionFields == null) { return(true); } if (relationFilter == null) { relationFilter = Net.Vpc.Upa.Filters.Fields.Regular().And(Net.Vpc.Upa.Filters.Fields.ByList(relation.GetSourceRole().GetFields())); } Net.Vpc.Upa.Filters.FieldFilter actualFilter = Net.Vpc.Upa.Filters.Fields.As(conditionFields).Or(relationFilter); Net.Vpc.Upa.Entity entityManager = @event.GetEntity(); foreach (string updatedField in @event.GetUpdatesRecord().KeySet()) { if (actualFilter.Accept(entityManager.GetField(updatedField))) { return(true); } } return(false); }
public override sealed void OnPreUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { string name = @event.GetTrigger().GetName(); Net.Vpc.Upa.Persistence.EntityExecutionContext executioncontext = @event.GetContext(); if (AcceptUpdateTableHelper(@event)) { System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> v = CreateUpdatedCollection(@event.GetEntity(), @event.GetFilterExpression()); if (!(v.Count == 0)) { executioncontext.SetObject(name + ":toUpdate", v); } } }
public override void AfterUpdateHelper(Net.Vpc.Upa.Callbacks.UpdateEvent @event, Net.Vpc.Upa.Expressions.Expression updatedExpression) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Entity entity = @event.GetEntity(); entity.CreateUpdateQuery().Validate(GetFields(entity)).ByExpression(updatedExpression).Execute(); }
public override void OnUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */ { Net.Vpc.Upa.Impl.Context.DefaultEntityTriggerContext context = new Net.Vpc.Upa.Impl.Context.DefaultEntityTriggerContext(@event.GetEntity(), @event.GetTrigger(), @event.GetContext()); foreach (object aK in ResolveIdList(@event, @event.GetFilterExpression())) { keyInterceptor.AfterUpdate(context, aK, @event.GetUpdatesRecord()); } }