📄 coursetransactionmanager.java
字号:
package eols.logic.course;
import java.util.Map;
import eols.bean.course.*;
import eols.logic.base.ITransaction;
import eols.storage.base.IStorage;
import eols.storage.course.CourseStorageManager;
public class CourseTransactionManager implements ITransaction {
/* The storage manager used in this transaction manager */
private IStorage iSQL = new CourseStorageManager();
/**
* Return the storage manager used by this
* transaction manager.
*
* @return The used storage manager
*/
public IStorage getStorageManager(){
return iSQL;
}
/**
* Process the specified transaction. All necessary parameters are
* wrapped in a map which is provided by specific caller.
*
* <p>
* A runtime exception may be thrown out, according to specific
* transactions.
* </p>
*
* <p>
* In this subsystem, the parameters contains the type of the transaction,
* the necessary parameters of the transaction.
* </p>
*
* @param parameters Parameters to pass
* @return The handling result object
*/
public Object process(Map parameters){
// Get the transaction type
String type = (String)parameters.get("type");
if (type == null) {
throw new RuntimeException("The transaction type shall be specified.");
}
if (type.equals("CREATENEWCATEGORY")) { /** Create a new category */
Category newC = (Category)parameters.get("category");
if (iSQL.addRecord(newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("CREATENEWCOURSE")) { /** Create a new course */
Course newC = (Course)parameters.get("course");
if (iSQL.addRecord(newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("CREATENEWCHAPTER")) { /** Create a new chapter */
Chapter newC = (Chapter)parameters.get("chapter");
if (iSQL.addRecord(newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("CREATENEWCONTENT")) { /** Create a new content */
Content newC = (Content)parameters.get("content");
if (iSQL.addRecord(newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("CREATENEWWORD")) { /** Create a new word */
Word newC = (Word)parameters.get("word");
if (iSQL.addRecord(newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("UPDATECATEGORY")) { /** Update the existing category */
Category newC = (Category)parameters.get("category");
if (iSQL.updateRecord(null, newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("UPDATECOURSE")) { /** Update the existing course */
Course newC = (Course)parameters.get("course");
if (iSQL.updateRecord(null, newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("UPDATECHAPTER")) { /** Update the existing chapter */
Chapter newC = (Chapter)parameters.get("chapter");
if (iSQL.updateRecord(null, newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("UPDATECONTENT")) { /** Update the existing content */
Content newC = (Content)parameters.get("content");
if (iSQL.updateRecord(null, newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
if (type.equals("UPDATEWORD")) { /** Update the existing word */
Word newC = (Word)parameters.get("word");
if (iSQL.updateRecord(null, newC)) {
return new Boolean(true);
}
return new Boolean(false);
}
return null;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -