📄 resourceaction.java
字号:
package cn.myapps.core.resource.action;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import cn.myapps.base.action.BaseAction;
import cn.myapps.base.action.ParamsTable;
import cn.myapps.core.resource.ejb.ResourceProcess;
import cn.myapps.core.resource.ejb.ResourceVO;
import cn.myapps.core.user.action.WebUser;
import cn.myapps.util.ProcessFactory;
import com.opensymphony.webwork.ServletActionContext;
/**
* Resouce Action using the web-work framework.
*/
public class ResourceAction extends BaseAction {
private static Collection _topmenus;
private String isprotected;
/**
* @throws Exception
*/
public ResourceAction() throws Exception {
super(ProcessFactory.createProcess(ResourceProcess.class),
new ResourceVO());
}
/**
* The navitesup action
*
* @return "sucess".
* @throws Exception
*/
public String doNavigatesup() throws Exception {
return SUCCESS;
}
/**
* Retrieve the top menus.
*
* @return Returns the top menus collection.
* @throws Exception
*/
public Collection get_topmenus(String application) throws Exception {
if (_topmenus == null || true) {
_topmenus = getSubMenus(null, application);
}
return _topmenus;
}
/**
* Retrieve the sub menus (get the parent menu id from the web paramenter).
*
* @return The sub menus collection.
* @throws Exception
*/
public Collection get_submenus(String application) throws Exception {
String _pid = ServletActionContext.getRequest().getParameter("_parent");
ResourceVO parent = (ResourceVO) proxy.doView(_pid);
Collection menus = null;
// if (parent != null) {
menus = getSubMenus(parent, application);
// parent.setSuperiorid("-1");
// menus.add(parent);
// }
return menus;
}
/**
* Retrieve the sub menus
*
* @param startNode
* The parent menu.
* @return The sub menus under the parment menu.
* @throws Exception
*/
public Collection getSubMenus(ResourceVO startNode, String application) throws Exception {
ArrayList list = new ArrayList();
ParamsTable params = new ParamsTable();
params.setParameter("_orderby"," orderno");
Collection cols = proxy.doSimpleQuery(params, application);
Iterator iter = cols.iterator();
while (iter.hasNext()) {
ResourceVO vo = (ResourceVO) iter.next();
if (startNode == null) {
if (vo.getSuperior() == null) {
list.add(vo);
}
} else {
if (vo.getSuperior() != null) {
ResourceVO Superior=vo.getSuperior();
while(Superior!=null)
{
if(Superior.getId().equals(startNode.getId()))
{
list.add(vo);
break;
}
Superior=Superior.getSuperior();
}
}
}
}
return list;
}
public Map get_menus(String application) throws Exception {
Collection dc = proxy.doSimpleQuery(null, application);
Map dm = ((ResourceProcess) proxy).deepSearchMenuTree(dc, null,
getContent().getId(), 0);
return dm;
}
public String get_superiorid() {
ResourceVO resource = (ResourceVO) getContent();
if (resource.getSuperior() != null) {
return resource.getSuperior().getId();
} else {
return null;
}
}
public void set_superiorid(String _superiorid) {
ResourceVO content = (ResourceVO) this.getContent();
try {
ResourceVO superior = (ResourceVO) proxy.doView(_superiorid);
content.setSuperior(superior);
} catch (Exception e) {
e.printStackTrace();
}
}
public String getIsprotected() {
if (((ResourceVO)getContent()).isIsprotected())
return "true";
else
return "false";
}
public void setIsprotected(String isprotected) {
if(isprotected.equals("true"))
((ResourceVO)getContent()).setIsprotected(true);
else
((ResourceVO)getContent()).setIsprotected(false);
this.isprotected = isprotected;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -