⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 genericusergroupmgr.java

📁 Sequoia ERP是一个真正的企业级开源ERP解决方案。它提供的模块包括:电子商务应用(e-commerce), POS系统(point of sales),知识管理,存货与仓库管理
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
        try {            delegator.create(rollup);        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }    }    public void removeGroupFromGroup(UserTransaction trans, String parentGroup, String group) throws RootException {        GenericValue rollup = getGroupRollup(parentGroup, group);        if (rollup != null) {            try {                rollup.remove();            } catch (GenericEntityException e) {                Debug.logError(e, module);                throw new RootException(e);            }        }    }    public void removeGroupTree(UserTransaction trans, String s) throws RootException {        // TODO: Implement Me!    }    public void removeUsersFromGroupTree(UserTransaction trans, String s) throws RootException {        // TODO: Implement Me!    }    public void moveGroup(UserTransaction trans, String currentParentGroup, String newParentGroup, String groupName) throws RootException {        this.removeGroupFromGroup(trans, currentParentGroup, groupName);        this.addGroupToGroup(trans, newParentGroup, groupName);    }    public String getGroupDescription(UserTransaction trans, String groupName) throws RootException {        GenericValue group = getGroup(groupName);        if (group != null) {            return group.getString("description");        }        return null;    }    public void addUserToGroup(UserTransaction trans, String groupName, String username) throws RootException {        GenericDelegator delegator = SharkContainer.getDelegator();        GenericValue member = delegator.makeValue("SharkGroupMember", null);        member.set("groupName", groupName);        member.set("userName", username);        try {            delegator.create(member);        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }    }    public void removeUserFromGroup(UserTransaction trans, String groupName, String username) throws RootException {        GenericValue member = getGroupMember(groupName, username);        if (member != null) {            try {                member.remove();            } catch (GenericEntityException e) {                Debug.logError(e, module);                throw new RootException(e);            }        }    }    public void moveUser(UserTransaction trans, String currentGroup, String newGroup, String username) throws RootException {        this.removeUserFromGroup(trans, currentGroup, username);        this.addUserToGroup(trans, newGroup, username);    }    public boolean doesUserBelongToGroup(UserTransaction trans, String groupName, String username) throws RootException {        GenericValue member = getGroupMember(groupName, username);        if (member != null) {            return true;        }        return false;    }    public void createUser(UserTransaction trans, String groupName, String username, String password, String firstName, String lastName, String email) throws RootException {        GenericDelegator delegator = SharkContainer.getDelegator();        GenericValue user = delegator.makeValue("SharkUser", null);        user.set("userName", username);        user.set("firstName", firstName);        user.set("lastName", lastName);        user.set("passwd", password);        user.set("emailAddress", email);        try {            delegator.create(user);        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }        if (groupName != null) {            this.addUserToGroup(trans, groupName, username);        }    }    public void updateUser(UserTransaction trans, String username, String firstName, String lastName, String email) throws RootException {        GenericValue user = getUser(username);        if (user != null) {            user.set("firstName", firstName);            user.set("lastName", firstName);            user.set("emailAddress", email);            try {                user.store();            } catch (GenericEntityException e) {                Debug.logError(e, module);                throw new RootException(e);            }        }    }    public void removeUser(UserTransaction trans, String username) throws RootException {        GenericValue user = getUser(username);        if (user != null) {            try {                user.remove();            } catch (GenericEntityException e) {                Debug.logError(e, module);                throw new RootException(e);            }        }    }    public boolean doesUserExist(UserTransaction trans, String username) throws RootException {        GenericValue user = getUser(username);        if (user == null) {            return false;        }        return true;    }    public void setPassword(UserTransaction trans, String username, String password) throws RootException {        GenericValue user = getUser(username);        if (user != null) {            user.set("passwd", password);            try {                user.store();            } catch (GenericEntityException e) {                Debug.logError(e, module);                throw new RootException(e);            }        }    }    public String getUserRealName(UserTransaction trans, String username) throws RootException {        StringBuffer buf = new StringBuffer();        GenericValue user = getUser(username);        if (!UtilValidate.isEmpty(user.getString("firstName"))) {            buf.append(user.getString("firstName"));        }        if (!UtilValidate.isEmpty(user.getString("lastName"))) {            if (buf.length() > 0) {                buf.append(" ");            }            buf.append(user.getString("lastName"));        }        return buf.toString();    }    public String getUserFirstName(UserTransaction trans, String username) throws RootException {        GenericValue user = getUser(username);        return user.getString("firstName");    }    public String getUserLastName(UserTransaction trans, String username) throws RootException {        GenericValue user = getUser(username);        return user.getString("lastName");    }    public String getUserEMailAddress(UserTransaction trans, String username) throws RootException {        GenericValue user = getUser(username);        if (user != null) {            return user.getString("emailAddress");        }        return null;    }    private GenericValue getUser(String username) throws RootException {        GenericDelegator delegator = SharkContainer.getDelegator();        GenericValue value = null;        try {            value = delegator.findByPrimaryKey("SharkUser", UtilMisc.toMap("userName", username));        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }        return value;    }    private GenericValue getGroup(String groupName) throws RootException {        GenericDelegator delegator = SharkContainer.getDelegator();        GenericValue value = null;        try {            value = delegator.findByPrimaryKey("SharkGroup", UtilMisc.toMap("groupName", groupName));        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }        return value;    }    private GenericValue getGroupMember(String groupName, String username) throws RootException {        GenericDelegator delegator = SharkContainer.getDelegator();        GenericValue member = null;        try {            member = delegator.findByPrimaryKey("SharkGroupMember", UtilMisc.toMap("groupName", groupName, "userName", username));        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }        return member;    }    private GenericValue getGroupRollup(String parentGroup, String group) throws RootException {        GenericDelegator delegator = SharkContainer.getDelegator();        GenericValue rollup = null;        try {            rollup = delegator.findByPrimaryKey("SharkGroupRollup", UtilMisc.toMap("parentGroupName", parentGroup, "groupName", group));        } catch (GenericEntityException e) {            Debug.logError(e, module);            throw new RootException(e);        }        return rollup;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -