Created
February 2, 2013 12:09
-
-
Save metametaclass/4697036 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| private void Process(IGetChangeLog chng, ChangeLogTableData changeData) { | |
| mLog.VerboseFormat("Process: {0}", chng); | |
| CheckIsInheritedFinished(chng.CHL_OPER); | |
| TableData td=null; | |
| TableData tmp; | |
| int sign=0; | |
| switch(chng.CHL_OPER) { | |
| case LogOperations.Insert: | |
| case LogOperations.AppendLogOnly: | |
| case LogOperations.InsertV: | |
| if(mFirst!=null) { | |
| throw new BaseBrainException("mFirst is not null in single table data {0}", chng); | |
| } | |
| td = new TableData(chng, changeData); | |
| sign = 1; | |
| break; | |
| case LogOperations.Delete: | |
| case LogOperations.DeleteV: | |
| if(mFirst!=null) { | |
| throw new BaseBrainException("mFirst is not null in single table data {0}", chng); | |
| } | |
| td = new TableData(chng, changeData); | |
| sign = -1; | |
| break; | |
| case LogOperations.DeleteObject: | |
| if(mFirst!=null) { | |
| throw new BaseBrainException("mFirst is not null in single table data {0}", chng); | |
| } | |
| mFirst = new TableData(chng, changeData); | |
| mInheritedProcessMode = InheritedProcessMode.DeleteObject; | |
| break; | |
| case LogOperations.UpdateOld: | |
| case LogOperations.UpdateOldV: | |
| case LogOperations.NewVersion: | |
| if(mFirst!=null) { | |
| throw new BaseBrainException("mFirst is not null in first data of pair/multiple object {0}", chng); | |
| } | |
| mFirst = new TableData(chng, changeData); | |
| break; | |
| case LogOperations.NewObject: | |
| mFirst = new TableData(chng, changeData); | |
| mInheritedProcessMode = InheritedProcessMode.NewObject; | |
| break; | |
| case LogOperations.NewObjectInherited: | |
| case LogOperations.NewVersionInherited: | |
| if(mFirst==null) { | |
| throw new BaseBrainException("mFirst is null in data of inherited {0}", chng); | |
| } | |
| tmp = new TableData(chng, changeData); | |
| mInherited.Add(tmp); | |
| break; | |
| case LogOperations.UpdateNew: | |
| case LogOperations.UpdateNewV: | |
| if(mFirst==null) { | |
| throw new BaseBrainException("mFirst is null in second data of pair {0}", chng); | |
| } | |
| td = new TableData(chng, changeData); | |
| break; | |
| case LogOperations.MarkOldVersion: | |
| if(mFirst==null) { | |
| throw new BaseBrainException("mFirst is null in second data of pair {0}", chng); | |
| } | |
| //swap mFirst(new version) and td(mark old) | |
| mSecond = mFirst; | |
| mInheritedSecond.AddRange(mInherited); | |
| mInherited.Clear(); | |
| mFirst = new TableData(chng, changeData); | |
| mInheritedProcessMode = InheritedProcessMode.MarkOld; | |
| break; | |
| case LogOperations.MarkOldVersionInherited: | |
| case LogOperations.DeleteObjectInherited: | |
| tmp = new TableData(chng, changeData); | |
| mInherited.Add(tmp); | |
| break; | |
| case LogOperations.DummyUpdate: | |
| case LogOperations.DummyUpdateV: | |
| //TODO: process in inherited data | |
| if(mFirst!=null) | |
| mLog.WarnFormat("Process: dummy update with mFirst!=null {0} {1}", chng, mFirst); | |
| /*if(mIsNewObject) | |
| mLog.WarnFormat("Process: dummy update new object flag {0} ", mFirst);*/ | |
| return;//do nothing with dummy updates; | |
| default: | |
| throw new BaseBrainException("Invalid operation code {0} in {1}", chng.CHL_OPER, chng); | |
| } | |
| ChangeLogOperation chd=null; | |
| if(mFirst==null && td==null) { | |
| throw new BaseBrainException("Invalid ChangeLog parser state in {0}", chng); | |
| } | |
| if(mFirst==null && td!=null) { | |
| switch(sign) { | |
| case -1: | |
| chd = new ChangeLogOperationSingleOld(chng.CHL_OPER, chng, td); | |
| break; | |
| case 1: | |
| chd = new ChangeLogOperationSingleNew(chng.CHL_OPER, chng, td); | |
| break; | |
| default: | |
| throw new BaseBrainException("Invalid sign in {0} {1}", chng, changeData); | |
| } | |
| } | |
| if(mFirst!=null && td!=null) { | |
| chd = new ChangeLogOperationPair(chng.CHL_OPER, mFirst.ChangeLog, mFirst, td, | |
| mInherited.ToArray(), mInheritedSecond.ToArray()); | |
| mInherited.Clear(); | |
| mFirst = null; | |
| } | |
| if(chd!=null) { | |
| ProcessChangeLogOperation(chd); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment