¡¡
 Document
 News
  • Releases
 Contact

¡¡

¡¡

 

                       System Operation History

                     Author: Chris Liao

                                   2006/12/31

 

                   Table of Content

¡¡

1.    Requirements

1.1.     Restore data.

1.2.     Record proof 

2.    Design

2.1.     Object List 

2.2.     Object Relationship

2.3.     Object Detail 

2.4.     Sample Code.

3.    Database

 

 

Revision History

Author

Date

version

Remark

Chris Liao

2006/12/31

1.0

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

1.     Requirements

1.1.  Restore data

When a new product is coming to user, system may be not stable during UAT period. Because users are not familiar with the work flow of the product, some mistaken operation will occur continually and some unavailable data will be created into DB. If a fatal mistake occurs in someday, users hope that all data can be restored to the time point before the error.

 

1.2.  Record proof

We often heard that users quarrel with each other on answering for mistakes, so managers hope to find a way to record Database change in background. For this, user¡¯s operation history should be stored in DB, and then we query them from DB table.

 

2.     Design

2.1.  Object List

Class

Type

Responsibility

Relative data

FieldChange

Entity

Represent as a value changed Field

TableChange

TableChange

Entity

Represent as a changed record, contain Some FieldChange object

Table:TB_Operation_History

ChangeProcessBean

Process

Represent as a business interface to operate history table.

TableChange

2.2.  Object Relationship

2.3.  Object Detail

Ø         FieldChange:

An entity object and describe field change in DB tables and store two values for field, one is before changing and another is after changing.

 

Member Name

Description

Remark

fieldName

DB field

 

fieldType

Field type

 

preValue

Value before changing

 

curValue

Value after changing

 

 

 

Ø         TableChange:

An entity object and describe table change in DB

 

Member and Method

Description

Remark

tablename

Table name

 

operation

Operation type

Create(Cre)

Update(Upd)

Delete(Del)

operator

Operator

 

oprDate

Operation data

 

fieldList

 

A list contain objects with form of FieldChange:

 

addFielchange()

 

Add a field change to TableChange

 

 

Ø         ChangeProccessBean

A process object to handle DB table: TB_Operation_History. This bean provides some methods to record data change in DB; these methods should be applied in your code.

 

Method Name

Description

Remark

handleUpdate

Record data update, insert a new record into table with ¡°UPD¡± flag

 

handleCreate

Record data update, insert a new record into table with ¡°CRT¡± flag

 

handleDelete

Record data delete, insert a new record into table with ¡°DEL¡± flag

 

restore

Restore DB data to some moment

Please don¡¯t use the method at a venture

 

Record SQL:

 

Insert into TB_Operation_History values (

tablename, operator,

operation, operateDate,

changeFieldList);,

 

Restore SQL

1: delete creation record

 

Delete from? where (?)

 

2: resore updated record

 

Update?  set (? )  where (?)

 

3: restore deleted record

 

Insert into ?(?) values(?)

 

 

2.4.  Sample Code

1: Record create action

 

  Insert into table_XXX (A1, A2, A3, A4) values (?, ?, ?, ?,?);

  ¡­¡­¡­¡­..// SQL execute

 

TableChange change = new TableChange();

 change. addFieldChange(¡°A1¡±,¡±String¡±,¡±Current Value¡±,¡± Previous Value¡±);

change. addFieldChange(¡°A2¡±,¡±String¡±,¡±Current Value¡±,¡± Previous Value¡±);

change. addFieldChange(¡°A3¡±,¡±String¡±,¡±Current Value¡±,¡± Previous Value¡±);

change. addFieldChange(¡°A4¡±,¡±String¡±,¡±Current Value¡±,¡± Previous Value¡±);

ChangeProccessBean. handleCreate(change);

¡­¡­¡­¡­¡­..

 

 

 

Note that: Delete action and update action are similar with this.

 

2: restore DB data

 

¡­¡­¡­¡­..

   ChangeProccessBean. restore(date);

   ¡­¡­¡­¡­¡­

3.   Database

Table Structure: TB_Operation_History

Field Name

Field Type

Description

TableName

Varchar(20)

 

Operation

Varchar(3)

 

Operator

Varchar(10)

 

OprTime

Date

 

ChangeFields

Blob

 

 

Date format of Field: ChangeFields

¡­<fieldName:FieldType:preValue:curValue>;<fieldName:FieldType:preValue:curValue>...

 

 

 

Copyright © 2006 . All Rights Reserved.