public FakeBidirectionalRelationWorkUnit(FakeBidirectionalRelationWorkUnit original, IAuditWorkUnit nestedWorkUnit)
            : base(original.sessionImplementor, original.EntityName, original.verCfg, original.EntityId)
        {
            this.nestedWorkUnit = nestedWorkUnit;

            fakeRelationChanges = new Dictionary <String, FakeRelationChange>(original.getFakeRelationChanges());
        }
Example #2
0
        public void AddWorkUnit(IAuditWorkUnit vwu)
        {
            if (vwu.ContainsWork()) {
                Object entityId = vwu.EntityId;

                if (entityId == null) {
                    // Just adding the work unit - it's not associated with any persistent entity.
                    //ORIG: workUnits.offer(vwu);
                    workUnits.AddLast(vwu);
                } else {
                    String entityName = vwu.EntityName;
                    Pair<String, Object> usedIdsKey = Pair<String, Object>.Make(entityName, entityId);

                    if (usedIds.ContainsKey(usedIdsKey)) {
                        IAuditWorkUnit other = usedIds[usedIdsKey];

                        IAuditWorkUnit result = vwu.Dispatch(other);

                        if (result != other) {
                            RemoveWorkUnit(other);

                            if (result != null) {
                                usedIds.Add(usedIdsKey, result);
                                workUnits.AddLast(result);
                            } // else: a null result means that no work unit should be kept
                        } // else: the result is the same as the work unit already added. No need to do anything.
                    } else {
                        usedIds.Add(usedIdsKey, vwu);
                        workUnits.AddLast(vwu);
                    }
                }
            }
        }
        public FakeBidirectionalRelationWorkUnit(FakeBidirectionalRelationWorkUnit original, IAuditWorkUnit nestedWorkUnit)
            : base(original.sessionImplementor, original.EntityName, original.verCfg, original.EntityId)
        {
            this.nestedWorkUnit = nestedWorkUnit;

            fakeRelationChanges = new Dictionary<String, FakeRelationChange>(original.getFakeRelationChanges());
        }
        private FakeBidirectionalRelationWorkUnit(FakeBidirectionalRelationWorkUnit original,
												 IDictionary<string, FakeRelationChange> fakeRelationChanges,
												 IAuditWorkUnit nestedWorkUnit)
            : base(original.SessionImplementor, original.EntityName, original.VerCfg, original.EntityId, original.RevisionType)
        {
            this.fakeRelationChanges = fakeRelationChanges;
            NestedWorkUnit = nestedWorkUnit;
        }
Example #5
0
        public static IAuditWorkUnit Merge(FakeBidirectionalRelationWorkUnit frwu, IAuditWorkUnit nestedFirst,
                                           IAuditWorkUnit nestedSecond)
        {
            var nestedMerged = nestedSecond.Dispatch(nestedFirst);

            // Creating a new fake relation work unit with the nested merged data
            return(new FakeBidirectionalRelationWorkUnit(frwu, nestedMerged));
        }
Example #6
0
 private FakeBidirectionalRelationWorkUnit(FakeBidirectionalRelationWorkUnit original,
                                           IDictionary <string, FakeRelationChange> fakeRelationChanges,
                                           IAuditWorkUnit nestedWorkUnit)
     : base(original.SessionImplementor, original.EntityName, original.VerCfg, original.EntityId, original.RevisionType)
 {
     this.fakeRelationChanges = fakeRelationChanges;
     NestedWorkUnit           = nestedWorkUnit;
 }
        public static IAuditWorkUnit merge(FakeBidirectionalRelationWorkUnit frwu, IAuditWorkUnit nestedFirst,
            IAuditWorkUnit nestedSecond)
        {
            IAuditWorkUnit nestedMerged = nestedSecond.Dispatch(nestedFirst);

            // Creating a new fake relation work unit with the nested merged data
            return new FakeBidirectionalRelationWorkUnit(frwu, nestedMerged);
        }
Example #8
0
 private void removeWorkUnit(IAuditWorkUnit vwu)
 {
     workUnits.Remove(vwu);
     if (vwu.IsPerformed())
     {
         // If this work unit has already been performed, it must be deleted (undone) first.
         undoQueue.Enqueue(vwu);
     }
 }
 private void RemoveWorkUnit(IAuditWorkUnit vwu) {
     workUnits.Remove(vwu);
     if (vwu.IsPerformed()) {
         // If this work unit has already been performed, it must be deleted (undone) first.
         //TODO Simon offer is more user friendly than add - see if C# Enqueue is compatible (also below)
         //ORIG: undoQueue.offer(vwu);
         undoQueue.Enqueue(vwu);
     }
 }
Example #10
0
 private void RemoveWorkUnit(IAuditWorkUnit vwu)
 {
     workUnits.Remove(vwu);
     if (vwu.IsPerformed())
     {
         // If this work unit has already been performed, it must be deleted (undone) first.
         //TODO Simon offer is more user friendly than add - see if C# Enqueue is compatible (also below)
         //ORIG: undoQueue.offer(vwu);
         undoQueue.Enqueue(vwu);
     }
 }
Example #11
0
        /// <summary>
        /// Notifies <see cref="IRevisionInfoGenerator"/> about changes made in the current revision. Provides information
        /// about modified entity class, entity name and its id, as well as <see cref="RevisionType"/> and revision log entity.
        /// </summary>
        /// <param name="currentRevisionData">Revision log entity.</param>
        /// <param name="vwu">Performed work unit.</param>
        public void EntityChanged(object currentRevisionData, IAuditWorkUnit vwu)
        {
            var entityId = vwu.EntityId;

            if (entityId is PersistentCollectionChangeWorkUnit.PersistentCollectionChangeWorkUnitId idAsPersistentColl)
            {
                entityId = idAsPersistentColl.OwnerId;
            }
            var entClass = Toolz.ResolveEntityClass(_sessionImplementor, vwu.EntityName);

            _revisionInfoGenerator.EntityChanged(entClass, vwu.EntityName, entityId, vwu.RevisionType, currentRevisionData);
        }
        public FakeBidirectionalRelationWorkUnit(ISessionImplementor sessionImplementor, String entityName,
                                                 AuditConfiguration verCfg, Object id,
                                                 String referencingPropertyName, Object owningEntity,
                                                 RelationDescription rd, RevisionType revisionType,
                                                 Object index,
                                                 IAuditWorkUnit nestedWorkUnit)
            : base(sessionImplementor, entityName, verCfg, id)
        {
            this.nestedWorkUnit = nestedWorkUnit;

            // Adding the change for the relation.
            fakeRelationChanges = new Dictionary <String, FakeRelationChange>();
            fakeRelationChanges.Add(referencingPropertyName, new FakeRelationChange(owningEntity, rd, revisionType, index));
        }
        public FakeBidirectionalRelationWorkUnit(ISessionImplementor sessionImplementor, String entityName,
            AuditConfiguration verCfg, Object id,
            String referencingPropertyName, Object owningEntity,
            RelationDescription rd, RevisionType revisionType,
            Object index,
            IAuditWorkUnit nestedWorkUnit)
            : base(sessionImplementor, entityName, verCfg, id)
        {
            this.nestedWorkUnit = nestedWorkUnit;

            // Adding the change for the relation.
            fakeRelationChanges = new Dictionary<String, FakeRelationChange>();
            fakeRelationChanges.Add(referencingPropertyName, new FakeRelationChange(owningEntity, rd, revisionType, index));
        }
Example #14
0
        public void AddWorkUnit(IAuditWorkUnit vwu)
        {
            if (!vwu.ContainsWork())
            {
                return;
            }

            var entityId = vwu.EntityId;

            if (entityId == null)
            {
                // Just adding the work unit - it's not associated with any persistent entity.
                //ORIG: workUnits.offer(vwu);
                workUnits.AddLast(vwu);
            }
            else
            {
                var entityName = vwu.EntityName;
                var usedIdsKey = new Tuple <string, object>(entityName, entityId);

                var other = alreadyScheduledWorkUnit(usedIdsKey);
                if (other != null)
                {
                    var result = vwu.Dispatch(other);

                    if (result != other)
                    {
                        removeWorkUnit(other);

                        if (result != null)
                        {
                            usedIds[usedIdsKey] = result;
                            workUnits.AddLast(result);
                        }                 // else: a null result means that no work unit should be kept
                    }                     // else: the result is the same as the work unit already added. No need to do anything.
                }
                else
                {
                    usedIds[usedIdsKey] = vwu;
                    workUnits.AddLast(vwu);
                }
            }
        }
Example #15
0
        public void AddWorkUnit(IAuditWorkUnit vwu)
        {
            if (vwu.ContainsWork())
            {
                Object entityId = vwu.EntityId;

                if (entityId == null)
                {
                    // Just adding the work unit - it's not associated with any persistent entity.
                    //ORIG: workUnits.offer(vwu);
                    workUnits.AddLast(vwu);
                }
                else
                {
                    String entityName = vwu.EntityName;
                    Pair <String, Object> usedIdsKey = Pair <String, Object> .Make(entityName, entityId);

                    if (usedIds.ContainsKey(usedIdsKey))
                    {
                        IAuditWorkUnit other = usedIds[usedIdsKey];

                        IAuditWorkUnit result = vwu.Dispatch(other);

                        if (result != other)
                        {
                            RemoveWorkUnit(other);

                            if (result != null)
                            {
                                usedIds.Add(usedIdsKey, result);
                                workUnits.AddLast(result);
                            } // else: a null result means that no work unit should be kept
                        }     // else: the result is the same as the work unit already added. No need to do anything.
                    }
                    else
                    {
                        usedIds.Add(usedIdsKey, vwu);
                        workUnits.AddLast(vwu);
                    }
                }
            }
        }
Example #16
0
        public void AddWorkUnit(IAuditWorkUnit vwu)
        {
            if (!vwu.ContainsWork()) return;

            var entityId = vwu.EntityId;
            if (entityId == null)
            {
                // Just adding the work unit - it's not associated with any persistent entity.
                //ORIG: workUnits.offer(vwu);
                workUnits.AddLast(vwu);
            }
            else
            {
                var entityName = vwu.EntityName;
                var usedIdsKey = new Pair<string, object>(entityName, entityId);

                var other = alreadyScheduledWorkUnit(usedIdsKey);
                if(other!=null)
                {
                    var result = vwu.Dispatch(other);

                    if (result != other)
                    {
                        removeWorkUnit(other);

                        if (result != null)
                        {
                            usedIds[usedIdsKey] = result;
                            workUnits.AddLast(result);
                        } // else: a null result means that no work unit should be kept
                    } // else: the result is the same as the work unit already added. No need to do anything.
                }
                else
                {
                    usedIds[usedIdsKey] = vwu;
                    workUnits.AddLast(vwu);
                }
            }
        }
        public override IAuditWorkUnit Merge(FakeBidirectionalRelationWorkUnit second)
        {
            // First merging the nested work units.
            IAuditWorkUnit mergedNested = second.getNestedWorkUnit().Dispatch(nestedWorkUnit);

            // Now merging the fake relation changes from both work units.
            IDictionary <String, FakeRelationChange> secondFakeRelationChanges = second.getFakeRelationChanges();
            IDictionary <String, FakeRelationChange> mergedFakeRelationChanges = new Dictionary <String, FakeRelationChange>();
            //TODO Simon - decide if we use IESI.Collections in the end.
            ISet <String> allPropertyNames = new HashedSet <String>(fakeRelationChanges.Keys);

            allPropertyNames.AddAll(secondFakeRelationChanges.Keys);

            foreach (String propertyName in allPropertyNames)
            {
                mergedFakeRelationChanges.Add(propertyName,
                                              FakeRelationChange.Merge(
                                                  fakeRelationChanges[propertyName],
                                                  secondFakeRelationChanges[propertyName]));
            }

            return(new FakeBidirectionalRelationWorkUnit(this, mergedFakeRelationChanges, mergedNested));
        }
Example #18
0
 private void removeWorkUnit(IAuditWorkUnit vwu)
 {
     workUnits.Remove(vwu);
     if (vwu.IsPerformed())
     {
         // If this work unit has already been performed, it must be deleted (undone) first.
         undoQueue.Enqueue(vwu);
     }
 }