本文整理汇总了Java中org.activiti.engine.identity.Group类的典型用法代码示例。如果您正苦于以下问题:Java Group类的具体用法?Java Group怎么用?Java Group使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Group类属于org.activiti.engine.identity包,在下文中一共展示了Group类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: afterPropertiesSet
import org.activiti.engine.identity.Group; //导入依赖的package包/类
public void afterPropertiesSet() throws Exception {
if (!Global.isSynActivitiIndetity()){
return;
}
if (isSynActivitiIndetity){
isSynActivitiIndetity = false;
// 同步角色数据
List<Group> groupList = identityService.createGroupQuery().list();
if (groupList.size() == 0){
Iterator<Role> roles = roleDao.findAllList(new Role()).iterator();
while(roles.hasNext()) {
Role role = roles.next();
saveActivitiGroup(role);
}
}
// 同步用户数据
List<org.activiti.engine.identity.User> userList = identityService.createUserQuery().list();
if (userList.size() == 0){
Iterator<User> users = userDao.findAllList(new User()).iterator();
while(users.hasNext()) {
saveActivitiUser(users.next());
}
}
}
}
示例2: initUserGroupTest
import org.activiti.engine.identity.Group; //导入依赖的package包/类
@Test
public void initUserGroupTest() {
// deptLeader
Group deptLeader = this.identityService.newGroup("deptLeader");
deptLeader.setName("部门领导");
deptLeader.setType("candidate");
identityService.saveGroup(deptLeader);
// hr
Group hr = this.identityService.newGroup("hr");
hr.setName("人事部领导");
hr.setType("candidate");
identityService.saveGroup(hr);
User admin = this.identityService.newUser("admin");
admin.setFirstName("xia");
admin.setLastName("liang");
admin.setEmail("[email protected]");
identityService.saveUser(admin);
identityService.createMembership("admin", "deptLeader");
identityService.createMembership("admin", "hr");
}
示例3: getGroupList
import org.activiti.engine.identity.Group; //导入依赖的package包/类
/**
* or 查询
*
* @param condition 查询条件 name (分组名称或type:code)
* @param pageInfo 分页信息
* @return
*/
@Override
public List<Group> getGroupList(QueryCondition condition, PageInfo pageInfo) {
String name = null;
if (condition != null) {
name = condition.getConditionMap().get("name").toString();
//groupId=condition.getConditionMap().get("groupId").toString();
}
List<Group> groupList;
long count;
String sql = "SELECT * FROM " + managementService.getTableName(Group.class) + " where 1=1 order by ID_";
if (!StrUtil.isEmpty(name)) {
sql = sql.replace("1=1", "NAME_ like '" + name + "' or TYPE_ like '" + name + "'");
}
NativeGroupQuery query = identityService.createNativeGroupQuery().sql(sql);
//native查询中一下查询会有异常
//count=query.count();
//改成如下,查询正常
count = identityService.createNativeGroupQuery().sql("select count(ID_) from (" + sql + ") t").count();
groupList = query.listPage((pageInfo.getPageNum() - 1) * pageInfo.getPageSize(), pageInfo.getPageSize());
pageInfo.setCount((int) count);
return groupList;
}
示例4: findGroupsByUser
import org.activiti.engine.identity.Group; //导入依赖的package包/类
@Override
public List<Group> findGroupsByUser(String userId) {
String sql = "select r.id id,name,code from tbl_role r" +
" left join tbl_user_role ur on r.id=ur.roleid" +
" where ur.userid=:userid";
Map<String, Object> param = new HashMap<>();
param.put("userid", userId);
List<Map<String, Object>> maps = super.findMapBySql(sql, param);
List<Group> groups = new ArrayList<>();
for (Map<String, Object> map : maps) {
Group group = new GroupEntity();
group.setId(map.get("id").toString());
group.setName(map.get("name").toString());
group.setType(map.get("code").toString());
groups.add(group);
}
return groups;
}
示例5: testGroup
import org.activiti.engine.identity.Group; //导入依赖的package包/类
/**
* 组管理API演示
*/
@Test
public void testGroup() throws Exception {
// 创建一个组对象
Group group = identityService.newGroup("deptLeader");
group.setName("部门领导");
group.setType("assignment");
// 保存组
identityService.saveGroup(group);
// 验证组是否已保存成功,首先需要创建组查询对象
List<Group> groupList = identityService.createGroupQuery().groupId("deptLeader").list();
assertEquals(1, groupList.size());
// 删除组
identityService.deleteGroup("deptLeader");
// 验证是否删除成功
groupList = identityService.createGroupQuery().groupId("deptLeader").list();
assertEquals(0, groupList.size());
}
示例6: setUp
import org.activiti.engine.identity.Group; //导入依赖的package包/类
@Before
public void setUp() throws Exception {
// 初始化7大Service实例
super.setUp();
// 创建并保存组对象
Group group = identityService.newGroup("deptLeader");
group.setName("部门领导");
group.setType("assignment");
identityService.saveGroup(group);
// 创建并保存用户对象
User user = identityService.newUser("henryyan");
user.setFirstName("Henry");
user.setLastName("Yan");
user.setEmail("[email protected]");
identityService.saveUser(user);
// 把用户henryyan加入到组deptLeader中
identityService.createMembership("henryyan", "deptLeader");
}
示例7: setCandidateUserAndGroups
import org.activiti.engine.identity.Group; //导入依赖的package包/类
/**
* 读取流程定义的相关候选启动人、组,根据link信息转换并封装为User、Group对象
* @param processDefinitionList
* @return
*/
private Map<String, Map<String, List<? extends Object>>> setCandidateUserAndGroups(List<ProcessDefinition> processDefinitionList) {
Map<String, Map<String, List<? extends Object>>> linksMap = new HashMap<String, Map<String, List<? extends Object>>>();
for (ProcessDefinition processDefinition : processDefinitionList) {
List<IdentityLink> identityLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId());
Map<String, List<? extends Object>> single = new Hashtable<String, List<? extends Object>>();
List<User> linkUsers = new ArrayList<User>();
List<Group> linkGroups = new ArrayList<Group>();
for (IdentityLink link : identityLinks) {
if (StringUtils.isNotBlank(link.getUserId())) {
linkUsers.add(identityService.createUserQuery().userId(link.getUserId()).singleResult());
} else if (StringUtils.isNotBlank(link.getGroupId())) {
linkGroups.add(identityService.createGroupQuery().groupId(link.getGroupId()).singleResult());
}
}
single.put("user", linkUsers);
single.put("group", linkGroups);
linksMap.put(processDefinition.getId(), single);
}
return linksMap;
}
示例8: saveGroup
import org.activiti.engine.identity.Group; //导入依赖的package包/类
/**
* 保存Group
*
* @return
*/
@RequestMapping(value = "group/save", method = RequestMethod.POST)
public String saveGroup(@RequestParam("groupId") String groupId,
@RequestParam("groupName") String groupName,
@RequestParam("type") String type,
RedirectAttributes redirectAttributes) {
Group group = identityService.createGroupQuery().groupId(groupId).singleResult();
if (group == null) {
group = identityService.newGroup(groupId);
}
group.setName(groupName);
group.setType(type);
identityService.saveGroup(group);
redirectAttributes.addFlashAttribute("message", "成功添加组[" + groupName + "]");
return "redirect:/chapter14/identity/group/list";
}
示例9: testCreateMembershipAlreadyExisting
import org.activiti.engine.identity.Group; //导入依赖的package包/类
public void testCreateMembershipAlreadyExisting() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
// Create the membership
identityService.createMembership(johndoe.getId(), sales.getId());
try {
identityService.createMembership(johndoe.getId(), sales.getId());
} catch(RuntimeException re) {
// Expected exception, membership already exists
}
identityService.deleteGroup(sales.getId());
identityService.deleteUser(johndoe.getId());
}
示例10: testDeleteMembership
import org.activiti.engine.identity.Group; //导入依赖的package包/类
public void testDeleteMembership() {
Group sales = identityService.newGroup("sales");
identityService.saveGroup(sales);
User johndoe = identityService.newUser("johndoe");
identityService.saveUser(johndoe);
// Add membership
identityService.createMembership(johndoe.getId(), sales.getId());
List<Group> groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
assertTrue(groups.size() == 1);
assertEquals("sales", groups.get(0).getId());
// Delete the membership and check members of sales group
identityService.deleteMembership(johndoe.getId(), sales.getId());
groups = identityService.createGroupQuery().groupMember(johndoe.getId()).list();
assertTrue(groups.size() == 0);
identityService.deleteGroup("sales");
identityService.deleteUser("johndoe");
}
示例11: GroupItem
import org.activiti.engine.identity.Group; //导入依赖的package包/类
public GroupItem(final Group group) {
Button idButton = new Button(group.getId());
idButton.addStyleName(Reindeer.BUTTON_LINK);
idButton.addListener(new ClickListener() {
public void buttonClick(ClickEvent event) {
ExplorerApp.get().getViewManager().showGroupPage(group.getId());
}
});
addItemProperty("id", new ObjectProperty<Button>(idButton, Button.class));
if (group.getName() != null) {
addItemProperty("name", new ObjectProperty<String>(group.getName(), String.class));
}
if (group.getType() != null) {
addItemProperty("type", new ObjectProperty<String>(group.getType(), String.class));
}
Embedded deleteIcon = new Embedded(null, Images.DELETE);
deleteIcon.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
deleteIcon.addListener(new DeleteMembershipListener(identityService, userId, group.getId(), userDetailPanel));
addItemProperty("actions", new ObjectProperty<Embedded>(deleteIcon, Embedded.class));
}
示例12: loadItems
import org.activiti.engine.identity.Group; //导入依赖的package包/类
public List<Item> loadItems(int start, int count) {
List<Item> groupItems = new ArrayList<Item>();
Set<String> currentGroups = getCurrentGroups();
int nrFound = 0;
int tries = 0;
while (nrFound == 0) { // must stop at some point in time, as otherwise size() would be reached
List<Group> groups = identityService.createGroupQuery()
.orderByGroupType().asc()
.orderByGroupId().asc()
.orderByGroupName().asc()
.listPage(start + (tries * count), count);
for (Group group : groups) {
if (!currentGroups.contains(group.getId())) {
nrFound++;
groupItems.add(new GroupSelectionItem(group));
}
}
tries++;
}
return groupItems;
}
示例13: getGroupsForCandidateUser
import org.activiti.engine.identity.Group; //导入依赖的package包/类
protected List<String> getGroupsForCandidateUser(String candidateUser) {
// TODO: Discuss about removing this feature? Or document it properly and maybe recommend to not use it
// and explain alternatives
List<Group> groups = Context.getCommandContext()
.getGroupIdentityManager().findGroupsByUser(candidateUser);
List<String> groupIds = new ArrayList<String>();
for (Group group : groups) {
groupIds.add(group.getId());
}
return groupIds;
}
示例14: findGroupsByUser
import org.activiti.engine.identity.Group; //导入依赖的package包/类
@Override
public List<Group> findGroupsByUser(String userId) {
logger.debug("findGroupsByUser : {}", userId);
List<Group> groups = new ArrayList<Group>();
for (OrgDTO orgDto : orgConnector.getOrgsByUserId(userId)) {
GroupEntity groupEntity = new GroupEntity(orgDto.getId());
groupEntity.setName(orgDto.getName());
groupEntity.setType(orgDto.getTypeName());
groups.add(groupEntity);
}
return groups;
}
示例15: findGroupsByUser
import org.activiti.engine.identity.Group; //导入依赖的package包/类
@Override
public List<Group> findGroupsByUser(final String id) {
if (id == null) {
return null;
}
try {
List<RoleEntity> sysRoles = userService.getUserRole(id);
return ActivitiUserUtil.toActivitiGroups(sysRoles);
} catch (EmptyResultDataAccessException e) {
return null;
}
}