📄 dictionarybean.java
字号:
package com.jlobo.web.views;
import org.apache.log4j.Logger;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.apache.myfaces.custom.tree2.TreeNode;
import com.jlobo.common.ContextHelper;
import com.jlobo.service.IDictionaryService;
import com.jlobo.web.beans.Dictionary;
import com.jlobo.web.beans.QuestionType;
import com.jlobo.web.beans.Subject;
public class DictionaryBean {
/**
* Logger for this class
*/
private static final Logger logger = Logger.getLogger(DictionaryBean.class);
public IDictionaryService dictionaryService;
private TreeNode dictionaryTree = null;
private TreeNode subjectTree =null;
private TreeNode typeTree = null;
private Subject subject = new Subject();
private DataModel subjects = new ListDataModel();
private Subject parentSubject = new Subject();
private Long currentSubject = 2200L;
private QuestionType type = new QuestionType();
private DataModel types = new ListDataModel();
private QuestionType parentType = new QuestionType();
private Long currentType = 2100L;
private DataModel dictionarys = new ListDataModel();
private Dictionary dictionary = new Dictionary();
private Long currentDictionary = -2L;
private Dictionary parentDictionary = new Dictionary();
public IDictionaryService getDictionaryService() {
return dictionaryService;
}
public void setDictionaryService(IDictionaryService dictionaryService) {
this.dictionaryService = dictionaryService;
}
public TreeNode getDictionaryTree() {
dictionaryTree = this.getDictionaryService().getDictionaryTree();
return dictionaryTree;
}
public void setDictionaryTree(TreeNode dictionaryTree) {
this.dictionaryTree = dictionaryTree;
}
public DataModel getDictionarys() {
dictionarys.setWrappedData(this.getDictionaryService().getDictionarys(currentDictionary));
return dictionarys;
}
public void setDictionarys(DataModel dictionarys) {
this.dictionarys = dictionarys;
}
public Dictionary getDictionary() {
return dictionary;
}
public void setDictionary(Dictionary dictionary) {
this.dictionary = dictionary;
}
//字典处理
public String insertDictionaryAction(){
dictionary = new Dictionary();
parentDictionary = this.getDictionaryService().getDictionary(parentDictionary.getId());
dictionary.setParent(parentDictionary);
dictionary.setSort(0L);
dictionary.setStatus("0");
return "Dictionary:Insert";
}
public String modifyDictionaryAction(){
Long did = Long.parseLong(ContextHelper.getParameter("dict_id"));
dictionary = this.getDictionaryService().getDictionary(did);
parentDictionary = dictionary.getParent();
return "Dictionary:Edit";
}
public String deleteDictionaryAction(){
Long did = Long.parseLong(ContextHelper.getParameter("dict_id"));
dictionary = this.getDictionaryService().getDictionary(did);
if(this.getDictionaryService().deleteDictionary(dictionary))
return "Dictionary:Failure";
return "Dictionary:Delete";
}
public String updateDicionaryAction(){
parentDictionary = this.getDictionaryService().getDictionary(parentDictionary.getId());
dictionary.setParent(parentDictionary);
if(!this.getDictionaryService().updateDictionary(dictionary))
return "Dictionary:Failure";
return "Dictionary:Update";
}
//考试科目处理
public String insertSubjectAction(){
subject = new Subject();
parentSubject = this.getDictionaryService().getSubject(parentSubject.getId());
subject.setParent(parentSubject);
subject.setSort(0L);
subject.setStatus("0");
return "Dictionary:Subject:Insert";
}
public String modifySubjectAction(){
Long did = Long.parseLong(ContextHelper.getParameter("dict_id"));
subject = this.getDictionaryService().getSubject(did);
parentSubject = subject.getParent();
return "Dictionary:Subject:Edit";
}
public String deleteSubjectAction(){
Long did = Long.parseLong(ContextHelper.getParameter("dict_id"));
subject = this.getDictionaryService().getSubject(did);
if(this.getDictionaryService().deleteSubject(subject))
return "Dictionary:Subject:Failure";
return "Dictionary:Subject:Delete";
}
public String updateSubjectAction(){
parentSubject = this.getDictionaryService().getSubject(parentSubject.getId());
subject.setParent(parentSubject);
if(!this.getDictionaryService().updateSubject(subject))
return "Dictionary:Subject:Failure";
return "Dictionary:Subject:Update";
}
public String toSubject(){
this.setCurrentSubject(Long.parseLong(ContextHelper.getParameter("currentSubject")));
this.parentSubject = this.getDictionaryService().getSubject(currentSubject);
return "Dictionary:Subject:List";
}
//试题类型处理
public String insertTypeAction(){
type = new QuestionType();
type = this.getDictionaryService().getType(parentType.getId());
type.setParent(parentType);
type.setSort(0L);
type.setStatus("0");
return "Dictionary:Type:Insert";
}
public String modifyTypeAction(){
Long did = Long.parseLong(ContextHelper.getParameter("dict_id"));
type = this.getDictionaryService().getType(did);
parentType = type.getParent();
return "Dictionary:Type:Edit";
}
public String deleteTypeAction(){
Long did = Long.parseLong(ContextHelper.getParameter("dict_id"));
type = this.getDictionaryService().getType(did);
if(this.getDictionaryService().deleteType(type))
return "Dictionary:Type:Failure";
return "Dictionary:Type:Delete";
}
public String updateTypeAction(){
parentType = this.getDictionaryService().getType(parentType.getId());
type.setParent(parentType);
if(!this.getDictionaryService().updateType(type))
return "Dictionary:Type:Failure";
return "Dictionary:Type:Update";
}
public String toType(){
this.setCurrentType(Long.parseLong(ContextHelper.getParameter("currentType")));
this.parentType = this.getDictionaryService().getType(currentType);
return "Dictionary:Type:List";
}
public String returnAction(){
return "Return";
}
public String toDictionary(){
this.setCurrentDictionary(Long.parseLong(ContextHelper.getParameter("curDict")));
this.parentDictionary = this.getDictionaryService().getDictionary(currentDictionary);
return "Dictionary:List";
}
public Long getCurrentDictionary() {
return currentDictionary;
}
public void setCurrentDictionary(Long currentDictionary) {
this.currentDictionary = currentDictionary;
}
public Dictionary getParentDictionary() {
return parentDictionary;
}
public void setParentDictionary(Dictionary parentDictionary) {
this.parentDictionary = parentDictionary;
}
public TreeNode getSubjectTree() {
subjectTree = this.getDictionaryService().getDictionarySubjectTree();
return subjectTree;
}
public void setSubjectTree(TreeNode subjectTree) {
this.subjectTree = subjectTree;
}
public TreeNode getTypeTree() {
typeTree = this.getDictionaryService().getDictionaryTypeTree();
return typeTree;
}
public void setTypeTree(TreeNode typeTree) {
this.typeTree = typeTree;
}
public Subject getSubject() {
return subject;
}
public void setSubject(Subject subject) {
this.subject = subject;
}
public DataModel getSubjects() {
subjects.setWrappedData(this.getDictionaryService().getSubjects(currentSubject));
return subjects;
}
public void setSubjects(DataModel subjects) {
this.subjects = subjects;
}
public QuestionType getType() {
return type;
}
public void setType(QuestionType type) {
this.type = type;
}
public DataModel getTypes() {
types.setWrappedData(this.getDictionaryService().getTypes(currentType));
return types;
}
public void setTypes(DataModel types) {
this.types = types;
}
public Subject getParentSubject() {
return parentSubject;
}
public void setParentSubject(Subject parentSubject) {
this.parentSubject = parentSubject;
}
public QuestionType getParentType() {
return parentType;
}
public void setParentType(QuestionType parentType) {
this.parentType = parentType;
}
public Long getCurrentSubject() {
return currentSubject;
}
public void setCurrentSubject(Long currentSubject) {
this.currentSubject = currentSubject;
}
public Long getCurrentType() {
return currentType;
}
public void setCurrentType(Long currentType) {
this.currentType = currentType;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -