
org.activiti.engine.impl.persistence.entity.UserEntityManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of activiti-engine Show documentation
Show all versions of activiti-engine Show documentation
workflow engine base on bboss and activiti.
The newest version!
/* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.activiti.engine.impl.persistence.entity;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.activiti.engine.identity.Group;
import org.activiti.engine.identity.User;
import org.activiti.engine.identity.UserQuery;
import org.activiti.engine.impl.Page;
import org.activiti.engine.impl.UserQueryImpl;
import org.activiti.engine.impl.context.Context;
import org.activiti.engine.impl.db.DbSqlSession;
import org.activiti.engine.impl.db.PersistentObject;
import org.activiti.engine.impl.interceptor.CommandContext;
import org.activiti.engine.impl.persistence.AbstractManager;
/**
* @author Tom Baeyens
* @author Saeid Mirzaei
* @author Joram Barrez
*/
public class UserEntityManager extends AbstractManager {
public User createNewUser(String userId) {
return new UserEntity(userId);
}
public void insertUser(User user) {
getDbSqlSession().insert((PersistentObject) user);
}
public void updateUser(UserEntity updatedUser) {
CommandContext commandContext = Context.getCommandContext();
DbSqlSession dbSqlSession = commandContext.getDbSqlSession();
dbSqlSession.update(updatedUser);
}
public UserEntity findUserById(String userId) {
return (UserEntity) getDbSqlSession().selectOne("selectUserById", userId);
}
@SuppressWarnings("unchecked")
public void deleteUser(String userId) {
UserEntity user = findUserById(userId);
if (user!=null) {
if (user.getPictureByteArrayId()!=null) {
getByteArrayManager().deleteByteArrayById(user.getPictureByteArrayId());
}
List identityInfos = getDbSqlSession().selectList("selectIdentityInfoByUserId", userId);
for (IdentityInfoEntity identityInfo: identityInfos) {
getIdentityInfoManager().deleteIdentityInfo(identityInfo);
}
getDbSqlSession().delete("deleteMembershipsByUserId", userId);
getDbSqlSession().delete(user);
}
}
@SuppressWarnings("unchecked")
public List findUserByQueryCriteria(UserQueryImpl query, Page page) {
return getDbSqlSession().selectList("selectUserByQueryCriteria", query, page);
}
public long findUserCountByQueryCriteria(UserQueryImpl query) {
return (Long) getDbSqlSession().selectOne("selectUserCountByQueryCriteria", query);
}
@SuppressWarnings("unchecked")
public List findGroupsByUser(String userId) {
return getDbSqlSession().selectList("selectGroupsByUserId", userId);
}
public UserQuery createNewUserQuery() {
return new UserQueryImpl(Context.getProcessEngineConfiguration().getCommandExecutorTxRequired());
}
public IdentityInfoEntity findUserInfoByUserIdAndKey(String userId, String key) {
Map parameters = new HashMap();
parameters.put("userId", userId);
parameters.put("key", key);
return (IdentityInfoEntity) getDbSqlSession().selectOne("selectIdentityInfoByUserIdAndKey", parameters);
}
@SuppressWarnings("unchecked")
public List findUserInfoKeysByUserIdAndType(String userId, String type) {
Map parameters = new HashMap();
parameters.put("userId", userId);
parameters.put("type", type);
return (List) getDbSqlSession().getSqlSession().selectList("selectIdentityInfoKeysByUserIdAndType", parameters);
}
public Boolean checkPassword(String userId, String password) {
User user = findUserById(userId);
if ((user != null) && (password != null) && (password.equals(user.getPassword()))) {
return true;
}
return false;
}
@SuppressWarnings("unchecked")
public List findPotentialStarterUsers(String proceDefId) {
Map parameters = new HashMap();
parameters.put("procDefId", proceDefId);
return (List) getDbSqlSession().selectOne("selectUserByQueryCriteria", parameters);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy