Example #1
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 #2
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 #3
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 #4
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);
                }
            }
        }