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 static System.Collections.Generic.IList <object> ResolveIdListUtility(Net.Vpc.Upa.Callbacks.EntityEvent @event, Net.Vpc.Upa.Expressions.Expression whereExpression) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext();
     if (whereExpression is Net.Vpc.Upa.Expressions.IdExpression)
     {
         object id = ((Net.Vpc.Upa.Expressions.IdExpression)whereExpression).GetId();
         return(id == null ? new System.Collections.Generic.List <object>() : new System.Collections.Generic.List <object>(new[] { id }));
     }
     else
     {
         if (!executionContext.IsSet("ALL_IDS"))
         {
             if (@event.GetPhase() == Net.Vpc.Upa.EventPhase.AFTER)
             {
                 throw new Net.Vpc.Upa.Exceptions.UPAException("SingleEntityEventCalledInPostProcessButNeverInPreProcess");
             }
             System.Collections.Generic.IList <object> idList = @event.GetEntity().CreateQueryBuilder().ByExpression(whereExpression).GetIdList <K>();
             executionContext.SetObject("ALL_IDS", idList);
         }
         return((System.Collections.Generic.IList <object>)executionContext.GetObject <T>("ALL_IDS"));
     }
 }
Beispiel #3
0
 public override void OnUpdate(Net.Vpc.Upa.Callbacks.UpdateEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */
 {
     Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext();
     //        RelationRole detailRole = defaultTreeEntityExtensionSupport.getTreeRelation().getSourceRole();
     //        if (!map.isSet(detailRole.getField(0).getName())) {
     //            return;
     //        }
     System.Collections.Generic.IList <Net.Vpc.Upa.Field> updateTreeFields = GetUpdateTreeFields();
     if ([email protected]().IsSet(updateTreeFields[0].GetName()))
     {
         return;
     }
     System.Collections.Generic.IList <object> r = (System.Collections.Generic.IList <object>)executionContext.GetObject <T>("recurse");
     if (r != null)
     {
         foreach (object aR in r)
         {
             support.ValidatePathField(aR, executionContext);
             support.ValidateChildren(aR, executionContext);
         }
     }
 }
        public override sealed void OnRemove(Net.Vpc.Upa.Callbacks.RemoveEvent @event) /* throws Net.Vpc.Upa.Exceptions.UPAException */
        {
            Net.Vpc.Upa.Persistence.EntityExecutionContext executionContext = @event.GetContext();
            string name = @event.GetTrigger().GetName();

            System.Collections.Generic.ICollection <Net.Vpc.Upa.Key> collection = (System.Collections.Generic.ICollection <Net.Vpc.Upa.Key>)executionContext.GetObject <T>(name + ":toDelete");
            if (collection == null)
            {
                return;
            }
            executionContext.Remove(name + ":toDelete");
            if (!(collection.Count == 0))
            {
                AfterDeleteHelper(@event, CreateInCollection(@event.GetEntity(), collection));
            }
        }
Beispiel #5
0
        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");
                        }
                    }
                }
            }
        }