Skip to content

Commit

Permalink
实现接口
Browse files Browse the repository at this point in the history
  • Loading branch information
xuyongping committed Mar 7, 2012
1 parent 9549b50 commit c602e56
Show file tree
Hide file tree
Showing 14 changed files with 579 additions and 88 deletions.
Expand Up @@ -5,13 +5,14 @@

import com.ibatis.sqlmap.client.SqlMapClient;
import com.scss.db.connpool.config.IbatisConfig;
import com.scss.db.dao.i.IAcl;
import com.scss.db.exception.SameNameException;
import com.scss.db.model.ScssAcl;
/**
*
* @author Jack.wu.xu
*/
public class ScssAclDaoImpl {
public class ScssAclDaoImpl implements IAcl{
private static final SqlMapClient sqlMap = IbatisConfig.getSqlMapInstance();
private static ScssAclDaoImpl instance = new ScssAclDaoImpl();

Expand All @@ -21,8 +22,8 @@ private ScssAclDaoImpl() {
public static ScssAclDaoImpl getInstance() {
return instance;
}

public ScssAcl insertAcl(ScssAcl acl) throws SameNameException {
@Override
public ScssAcl insert(ScssAcl acl) throws SameNameException {
try {
acl.setId((Long) sqlMap.insert("putAcl", acl));
} catch (com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException e) {
Expand All @@ -37,8 +38,8 @@ public ScssAcl insertAcl(ScssAcl acl) throws SameNameException {
}
return acl;
}

public ScssAcl getAcl(Long id) {
@Override
public ScssAcl get(Long id) {
ScssAcl acl = null;
try {
acl = (ScssAcl) sqlMap.queryForObject("getAcl", id);
Expand All @@ -48,8 +49,8 @@ public ScssAcl getAcl(Long id) {
return acl;
}


public List<ScssAcl> getAclByAccessor(Long acc,String accType) {
@Override
public List<ScssAcl> getByAccessor(Long acc,String accType) {
List<ScssAcl> acls = null;
try {
ScssAcl acl = new ScssAcl();
Expand All @@ -61,7 +62,8 @@ public List<ScssAcl> getAclByAccessor(Long acc,String accType) {
}
return acls;
}
public List<ScssAcl> getAclOnResouce(Long res,String resType) {
@Override
public List<ScssAcl> getOnResouce(Long res,String resType) {
List<ScssAcl> acls = null;
try {
ScssAcl acl = new ScssAcl();
Expand All @@ -73,8 +75,8 @@ public List<ScssAcl> getAclOnResouce(Long res,String resType) {
}
return acls;
}

public ScssAcl getAclByAccessorOnResouce(Long acc,String accType, Long res,String resType) {
@Override
public ScssAcl getByAccessorOnResouce(Long acc,String accType, Long res,String resType) {
ScssAcl acls = null;
try {
ScssAcl acl = new ScssAcl();
Expand All @@ -88,12 +90,12 @@ public ScssAcl getAclByAccessorOnResouce(Long acc,String accType, Long res,Strin
}
return acls;
}

public void updateAcl(ScssAcl acl) throws SQLException {
@Override
public void update(ScssAcl acl) throws SQLException {
sqlMap.update("updateAcl", acl);
}

public void deleteAcl(ScssAcl acl) throws SQLException {
@Override
public void delete(ScssAcl acl) throws SQLException {
sqlMap.update("deleteAcl", acl);
}
}
Expand Up @@ -5,6 +5,7 @@

import com.ibatis.sqlmap.client.SqlMapClient;
import com.scss.db.connpool.config.IbatisConfig;
import com.scss.db.dao.i.IBucket;
import com.scss.db.exception.SameNameException;
import com.scss.db.model.ScssBucket;
import com.scss.db.model.ScssUser;
Expand All @@ -13,13 +14,13 @@
*
* @author Jack.wu.xu
*/
public class ScssBucketDaoImpl {
public class ScssBucketDaoImpl implements IBucket{
private static final SqlMapClient sqlMap = IbatisConfig.getSqlMapInstance();
private static ScssBucketDaoImpl instance = new ScssBucketDaoImpl();

private ScssBucketDaoImpl() {
}

@Override
public ScssBucket insertBucket(ScssBucket bucket) throws SameNameException,
SQLException {
try {
Expand All @@ -40,57 +41,57 @@ public ScssBucket insertBucket(ScssBucket bucket) throws SameNameException,
}
return bucket;
}

public ScssBucket getBucket(ScssBucket sb) {
@Override
public ScssBucket get(ScssBucket sb) {
try {
return (ScssBucket) sqlMap.queryForObject("getBucket", sb.getId());
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

public List<ScssBucket> getBuckets() {
@Override
public List<ScssBucket> get() {
try {
return sqlMap.queryForList("getBuckets");
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

public List<ScssBucket> getBucketsByUser(ScssUser user) {
@Override
public List<ScssBucket> getByUser(ScssUser user) {
try {
return sqlMap.queryForList("getBucketsByUser", user);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

public ScssBucket getBucket(Long id) {
@Override
public ScssBucket get(Long id) {
try {
return (ScssBucket) sqlMap.queryForObject("getBucket", id);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

public ScssBucket getBucket(String name) {
@Override
public ScssBucket get(String name) {
try {
return (ScssBucket) sqlMap.queryForObject("getBucketByName", name);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}

public void updateBucket(ScssBucket sb) throws SQLException {
@Override
public void update(ScssBucket sb) throws SQLException {
sqlMap.update("updateBucket", sb);
}

public void deleteBucket(ScssBucket sb) throws SQLException {
@Override
public void delete(ScssBucket sb) throws SQLException {
sqlMap.update("deleteBucket", sb);
}

Expand Down
Expand Up @@ -4,13 +4,15 @@

import com.ibatis.sqlmap.client.SqlMapClient;
import com.scss.db.connpool.config.IbatisConfig;
import com.scss.db.dao.i.IBucketLifecycle;
import com.scss.db.exception.SameNameException;
import com.scss.db.model.ScssBucketLifecycle;

/**
*
* @author Jack.wu.xu
*/
public class ScssBucketLifecycleDaoImpl {
public class ScssBucketLifecycleDaoImpl implements IBucketLifecycle {
private static final SqlMapClient sqlMap = IbatisConfig.getSqlMapInstance();
private static ScssBucketLifecycleDaoImpl instance = new ScssBucketLifecycleDaoImpl();

Expand All @@ -21,8 +23,9 @@ public static ScssBucketLifecycleDaoImpl getInstance() {
return instance;
}

public ScssBucketLifecycle insertBucketLifecycle(
ScssBucketLifecycle bucketLifecycle) throws SameNameException {
@Override
public ScssBucketLifecycle insert(ScssBucketLifecycle bucketLifecycle)
throws SameNameException {
try {
bucketLifecycle.setId((Long) sqlMap.insert("putBucketLifecycle",
bucketLifecycle));
Expand All @@ -37,7 +40,8 @@ public ScssBucketLifecycle insertBucketLifecycle(
return bucketLifecycle;
}

public ScssBucketLifecycle getBucketLifecycle(Long id) {
@Override
public ScssBucketLifecycle get(Long id) {
ScssBucketLifecycle acl = null;
try {
acl = (ScssBucketLifecycle) sqlMap.queryForObject(
Expand All @@ -48,11 +52,13 @@ public ScssBucketLifecycle getBucketLifecycle(Long id) {
return acl;
}

public void updateBucketLifecycle(ScssBucketLifecycle sbl) throws SQLException {
@Override
public void update(ScssBucketLifecycle sbl) throws SQLException {
sqlMap.update("updateBucketLifecycle", sbl);
}

public void deleteBucketLifecycle(ScssBucketLifecycle sbl) throws SQLException {
@Override
public void delete(ScssBucketLifecycle sbl) throws SQLException {
sqlMap.update("deleteBucketLifecycle", sbl);
}
}
@@ -1,17 +1,20 @@
package com.scss.db.dao;

import java.sql.SQLException;
import java.util.List;

import com.ibatis.sqlmap.client.SqlMapClient;
import com.scss.db.connpool.config.IbatisConfig;
import com.scss.db.exception.UserInGroupException;
import com.scss.db.dao.i.IGroup;
import com.scss.db.exception.DBException;
import com.scss.db.model.ScssGroup;
import com.scss.db.model.ScssUser;

/**
*
* @author Jack.wu.xu
*/
public class ScssGroupDaoImpl {
public class ScssGroupDaoImpl implements IGroup {
private static final SqlMapClient sqlMap = IbatisConfig.getSqlMapInstance();
private static ScssGroupDaoImpl instance = new ScssGroupDaoImpl();

Expand All @@ -22,6 +25,7 @@ public static ScssGroupDaoImpl getInstance() {
return instance;
}

@Override
public ScssGroup getGroupById(Long groupId) {
ScssGroup su = null;
try {
Expand All @@ -32,17 +36,21 @@ public ScssGroup getGroupById(Long groupId) {
return su;
}

public ScssGroup getGroupByName(String name) {
ScssGroup su = null;
@Override
public ScssGroup getGroupByName(String name, Long ownerId) {
ScssGroup su = new ScssGroup();
su.setName(name);
su.setOwnerId(ownerId);
try {
su = (ScssGroup) sqlMap.queryForObject("getGroupByName", name);
return (ScssGroup) sqlMap.queryForObject("getGroupByName", su);
} catch (SQLException e) {
e.printStackTrace();
}
return su;
return null;
}

public ScssGroup insertGroup(ScssGroup group) {
@Override
public ScssGroup insert(ScssGroup group) {
try {
group.setId((Long) sqlMap.insert("putGroup", group));
} catch (SQLException e) {
Expand All @@ -51,27 +59,39 @@ public ScssGroup insertGroup(ScssGroup group) {
return group;
}

public void putUserToGroup(ScssUser user, ScssGroup sg)
throws SQLException {
@Override
public void putUserToGroup(ScssUser user, ScssGroup sg) throws DBException {
String userIds = sg.getUserIds();
if (userIds.indexOf("," + user.getId() + ",") != -1) {
return;
}
putUserIdsToGroup(user.getId() + "", sg);
}

public void removeUserFromGroup(ScssUser user, ScssGroup sg) throws SQLException {
@Override
public void removeUserFromGroup(ScssUser user, ScssGroup sg)
throws DBException {
String userIds = sg.getUserIds();
userIds = userIds.replaceAll("," + user.getId() + ",", ",");
sg.setUserIds(userIds);
sqlMap.update("updateGroup", sg);
try {
sqlMap.update("updateGroup", sg);
} catch (SQLException e) {
throw new DBException(e);
}
}

public void updateGroup(ScssGroup sg) throws SQLException {
sqlMap.update("updateGroup", sg);
@Override
public void update(ScssGroup sg) throws DBException {
try {
sqlMap.update("updateGroup", sg);
} catch (SQLException e) {
throw new DBException(e);
}
}

public void putUserIdsToGroup(String ids, ScssGroup sg) throws SQLException {
@Override
public void putUserIdsToGroup(String ids, ScssGroup sg) throws DBException {
if ((ids == null) || ("".equals(ids))) {
return;
}
Expand All @@ -81,14 +101,35 @@ public void putUserIdsToGroup(String ids, ScssGroup sg) throws SQLException {
else
newIds = newIds + ids + ",";
sg.setUserIds(newIds);
sqlMap.update("updateGroup", sg);
try {
sqlMap.update("updateGroup", sg);
} catch (SQLException e) {
throw new DBException(e);
}
}

@Override
public void delete(ScssGroup sg) throws DBException {
delete(sg.getId());
}

public void deleteGroup(ScssGroup sg) throws SQLException {
deleteGroup(sg.getId());
@Override
public void delete(Long gid) throws DBException {
try {
sqlMap.delete("deleteGroup", gid);
} catch (SQLException e) {
throw new DBException(e);
}
}

public static void deleteGroup(Long gid) throws SQLException {
sqlMap.delete("deleteGroup", gid);
@SuppressWarnings("unchecked")
@Override
public List<ScssGroup> getGroupByName(String name) {
try {
return sqlMap.queryForList("getGroupsByName", name);
} catch (SQLException e) {
e.printStackTrace();
}
return null;
}
}
Expand Up @@ -6,13 +6,14 @@

import com.ibatis.sqlmap.client.SqlMapClient;
import com.scss.db.connpool.config.IbatisConfig;
import com.scss.db.dao.i.ILog;
import com.scss.db.model.ScssLog;
import com.scss.db.model.ScssUser;
/**
*
* @author Jack.wu.xu
*/
public class ScssLogDaoImpl {
public class ScssLogDaoImpl implements ILog{
private static final SqlMapClient sqlMap = IbatisConfig.getSqlMapInstance();
private static ScssLogDaoImpl instance = new ScssLogDaoImpl();

Expand Down

0 comments on commit c602e56

Please sign in to comment.