📄 groupmanager.java
字号:
package com.sure.oa.addresslist;
/**
* <p>Title: OA</p>
* <p>Description: 国办项目</p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: sure</p>
* @author mengzy
* @version 1.0
*/
import java.sql.*;
import java.util.*;
import com.sure.businesslogic.*;
import com.sure.businessmodel.*;
import com.sure.dataabstraction.*;
import com.sure.util.*;
import com.sure.oa.orgnization.*;
public class GroupManager {
public GroupManager() {
}
/**
* 显示自定义群组
* @param start 开始位置
* @return 分页形式的群组列表
* @throws SQLException
* @throws DBPoolException
*/
public Page getGroupList(int start, int unitId) throws SQLException, DBPoolException{
Connection cn = DBManager.getConnection();
try{
String where = "where unitId = " + unitId + "";
Page p = GroupPersistent.load(cn, start, 10, where);
return p;
}
finally {
cn.close();
}
}
/**
* 获得某个单位的所有群组
* @throws SQLException
* @throws DBPoolException
*/
public Vector getGroupList(int unitId) throws SQLException, DBPoolException{
Connection cn = DBManager.getConnection();
try{
String where = "where unitId = " + unitId + "";
Vector v=GroupPersistent.load(cn,where);
return v;
}
finally {
cn.close();
}
}
public Vector getGroupListHavePrintNum(int unitId) throws SQLException, DBPoolException{
Connection cn = DBManager.getConnection();
try{
String where = "where unitId = " + unitId + " and printNum <> ''";
Vector v=GroupPersistent.load(cn,where);
return v;
}
finally {
cn.close();
}
}
public Vector getGroupUnitList(int groupId) throws SQLException, DBPoolException,NotFoundException{
Connection cn = DBManager.getConnection();
String where="";
try{
Group group=getGroup(groupId);
String content=group.getContent();
String strIds[] = StringUtils.split(content, ",");
Vector v=new Vector();
Vector beans;
Unit u=new Unit();
UnitManager umg=new UnitManager();
int i;
for(i = 0; i < strIds.length; i++){
where = "Where unitId = " + strIds[i] + "";
beans = UnitPersistent.load(cn, where);
if (beans.size()>0){
u=(Unit)beans.firstElement();
v.add(u);
}
}
return v;
}
finally {
cn.close();
}
}
/**
* 获得详情
* @param groupId 群组id
* @return 群组详情
* @throws NotFoundException
* @throws DBPoolException
* @throws SQLException
*/
public Group getGroup(int groupId) throws NotFoundException, DBPoolException, SQLException{
Connection cn = DBManager.getConnection();
try{
String where = "where groupId = " + groupId + "";
Vector beans = GroupPersistent.load(cn, where);
Group bean = (Group)beans.firstElement();
return bean;
}
catch(SQLException se){
throw new NotFoundException();
}
finally {
cn.close();
}
}
/**
* 保存群组
* @param group 待保存的群组
* @return 保存结果
* @throws UpdateException
* @throws DBPoolException
* @throws SQLException
*/
public int saveGroup(Group group) throws UpdateException, DBPoolException, SQLException{
Connection cn = DBManager.getConnection();
String groupName = StringUtils.getSQLencode(group.getGroupName());
String where = "where groupName ='" + groupName + "' and unitId = '" + group.getUnitId() + "' and groupId <> '" + group.getGroupId() + "'";
int intResult = GroupPersistent.getCount(cn, where);
if(intResult > 0){
throw new UpdateException("本单位已经存在" + groupName + "这个群组");
}
int groupId = group.getGroupId().intValue();
int retval = 0;
try{
GroupPersistent groupPersistent = new GroupPersistent(group);
if(groupId == 0){
retval = 2;
}
else{
groupPersistent.setRecordExists(true);
retval = 3;
}
groupPersistent.persist(cn);
}
finally {
cn.close();
}
return retval;
}
/**
* 删除群组
* @param groupId 待删除的群组id
* @throws DBPoolException
* @throws SQLException
*/
public void deleteGroup(String groupId) throws DBPoolException, SQLException{
Connection cn = DBManager.getConnection();
try{
String where = "where groupId = '" + groupId + "'";
GroupPersistent.delete(cn, where);
}
finally {
cn.close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -