Java Code Examples for org.activiti.engine.identity.Group#setType()
The following examples show how to use
org.activiti.engine.identity.Group#setType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SaveGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); Random ran = new Random(10); for (int i = 0; i < 10; i++) { Group group = identityService.newGroup(String.valueOf(i)); group.setName("Group_" + ran.nextInt(10)); group.setType("TYPE_" + ran.nextInt(10)); identityService.saveGroup(group); } // 关闭流程引擎 engine.close(); }
Example 2
Source File: UserAndGroupInUserTaskTest.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
@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"); }
Example 3
Source File: GroupResourceTest.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
/** * Test deleting a single group. */ public void testDeleteGroup() throws Exception { try { Group testGroup = identityService.newGroup("testgroup"); testGroup.setName("Test group"); testGroup.setType("Test type"); identityService.saveGroup(testGroup); closeResponse(executeRequest(new HttpDelete(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")), HttpStatus.SC_NO_CONTENT)); assertNull(identityService.createGroupQuery().groupId("testgroup").singleResult()); } finally { try { identityService.deleteGroup("testgroup"); } catch (Throwable ignore) { // Ignore, since the group may not have been created in the test // or already deleted } } }
Example 4
Source File: GroupResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@ApiOperation(value = "Update a group", tags = {"Groups"}, notes = "All request values are optional. For example, you can only include the name attribute in the request body JSON-object, only updating the name of the group, leaving all other fields unaffected. When an attribute is explicitly included and is set to null, the group-value will be updated to null.") @ApiResponses(value = { @ApiResponse(code = 201, message = "Indicates the group was updated."), @ApiResponse(code = 404, message = "Indicates the requested group was not found."), @ApiResponse(code = 409, message = "Indicates the requested group was updated simultaneously.") }) @RequestMapping(value = "/identity/groups/{groupId}", method = RequestMethod.PUT, produces = "application/json") public GroupResponse updateGroup(@ApiParam(name="groupId") @PathVariable String groupId, @RequestBody GroupRequest groupRequest, HttpServletRequest request) { Group group = getGroupFromRequest(groupId); if (groupRequest.getId() == null || groupRequest.getId().equals(group.getId())) { if (groupRequest.isNameChanged()) { group.setName(groupRequest.getName()); } if (groupRequest.isTypeChanged()) { group.setType(groupRequest.getType()); } identityService.saveGroup(group); } else { throw new ActivitiIllegalArgumentException("Key provided in request body doesn't match the key in the resource URL."); } return restResponseFactory.createGroupResponse(group); }
Example 5
Source File: IdentityController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 保存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"; }
Example 6
Source File: IdentityController.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 保存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"; }
Example 7
Source File: IdmGroupsResource.java From activiti6-boot2 with Apache License 2.0 | 6 votes |
@RequestMapping(method = RequestMethod.POST) public GroupRepresentation createNewGroup(@RequestBody GroupRepresentation groupRepresentation) { validateAdminRole(); if (StringUtils.isBlank(groupRepresentation.getName())) { throw new BadRequestException("Group name required"); } Group newGroup = identityService.newGroup(groupRepresentation.getId()); newGroup.setName(groupRepresentation.getName()); if (groupRepresentation.getType() == null) { newGroup.setType(GroupTypes.TYPE_ASSIGNMENT); } else { newGroup.setType(groupRepresentation.getType()); } identityService.saveGroup(newGroup); return new GroupRepresentation(newGroup); }
Example 8
Source File: IdentityServiceTest.java From activiti-in-action-codes with Apache License 2.0 | 6 votes |
/** * 组管理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()); }
Example 9
Source File: SaveGroup.java From CrazyWorkflowHandoutsActiviti6 with MIT License | 6 votes |
public static void main(String[] args) { // 新建流程引擎 ProcessEngine engine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = engine.getIdentityService(); Random ran = new Random(10); for (int i = 0; i < 10; i++) { Group group = identityService.newGroup(String.valueOf(i)); group.setName("Group_" + ran.nextInt(10)); group.setType("TYPE_" + ran.nextInt(10)); identityService.saveGroup(group); } // 关闭流程引擎 engine.close(); }
Example 10
Source File: LogController.java From easyweb with Apache License 2.0 | 5 votes |
@ResponseBody @PostMapping("/test") @ApiOperation(value = "日志管理接口") public Object index(HttpServletRequest request, HttpServletResponse response) { ProcessEngine processEngine = ProcessEngines.getDefaultProcessEngine(); IdentityService identityService = processEngine.getIdentityService(); Group group = identityService.newGroup("SP2Admin"); group.setName("管理员组"); group.setType("manager"); identityService.saveGroup(group); return group; }
Example 11
Source File: GroupQueryTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private Group createGroup(String id, String name, String type) { Group group = identityService.newGroup(id); group.setName(name); group.setType(type); identityService.saveGroup(group); return group; }
Example 12
Source File: Application.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean InitializingBean usersAndGroupsInitializer(final IdentityService identityService) { return new InitializingBean() { @Override public void afterPropertiesSet() throws Exception { // install groups & users Group group = identityService.newGroup("user"); group.setName("users"); group.setType("security-role"); identityService.saveGroup(group); User joram = identityService.newUser("jbarrez"); joram.setFirstName("Joram"); joram.setLastName("Barrez"); joram.setPassword("password"); identityService.saveUser(joram); User josh = identityService.newUser("jlong"); josh.setFirstName("Josh"); josh.setLastName("Long"); josh.setPassword("password"); identityService.saveUser(josh); identityService.createMembership("jbarrez", "user"); identityService.createMembership("jlong", "user"); } }; }
Example 13
Source File: Application.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
@Bean CommandLineRunner seedUsersAndGroups(final IdentityService identityService) { return new CommandLineRunner() { @Override public void run(String... strings) throws Exception { // install groups & users Group group = identityService.newGroup("user"); group.setName("users"); group.setType("security-role"); identityService.saveGroup(group); User joram = identityService.newUser("jbarrez"); joram.setFirstName("Joram"); joram.setLastName("Barrez"); joram.setPassword("password"); identityService.saveUser(joram); User josh = identityService.newUser("jlong"); josh.setFirstName("Josh"); josh.setLastName("Long"); josh.setPassword("password"); identityService.saveUser(josh); identityService.createMembership("jbarrez", "user"); identityService.createMembership("jlong", "user"); } }; }
Example 14
Source File: GroupResourceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Test getting a single group. */ public void testGetGroup() throws Exception { try { Group testGroup = identityService.newGroup("testgroup"); testGroup.setName("Test group"); testGroup.setType("Test type"); identityService.saveGroup(testGroup); CloseableHttpResponse response = executeRequest(new HttpGet(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")), HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertEquals("testgroup", responseNode.get("id").textValue()); assertEquals("Test group", responseNode.get("name").textValue()); assertEquals("Test type", responseNode.get("type").textValue()); assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, testGroup.getId()))); Group createdGroup = identityService.createGroupQuery().groupId("testgroup").singleResult(); assertNotNull(createdGroup); assertEquals("Test group", createdGroup.getName()); assertEquals("Test type", createdGroup.getType()); } finally { try { identityService.deleteGroup("testgroup"); } catch (Throwable ignore) { // Ignore, since the group may not have been created in the test // or already deleted } } }
Example 15
Source File: GroupQueryEscapeClauseTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
private Group createGroup(String id, String name, String type) { Group group = identityService.newGroup(id); group.setName(name); group.setType(type); identityService.saveGroup(group); return group; }
Example 16
Source File: GroupResourceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Test updating a single group. */ public void testUpdateGroup() throws Exception { try { Group testGroup = identityService.newGroup("testgroup"); testGroup.setName("Test group"); testGroup.setType("Test type"); identityService.saveGroup(testGroup); ObjectNode requestNode = objectMapper.createObjectNode(); requestNode.put("name", "Updated group"); requestNode.put("type", "Updated type"); HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")); httpPut.setEntity(new StringEntity(requestNode.toString())); CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertEquals("testgroup", responseNode.get("id").textValue()); assertEquals("Updated group", responseNode.get("name").textValue()); assertEquals("Updated type", responseNode.get("type").textValue()); assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, testGroup.getId()))); Group createdGroup = identityService.createGroupQuery().groupId("testgroup").singleResult(); assertNotNull(createdGroup); assertEquals("Updated group", createdGroup.getName()); assertEquals("Updated type", createdGroup.getType()); } finally { try { identityService.deleteGroup("testgroup"); } catch (Throwable ignore) { // Ignore, since the group may not have been created in the test // or already deleted } } }
Example 17
Source File: GroupResourceTest.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
/** * Test updating a single group passing in no fields in the json, user should remain unchanged. */ public void testUpdateGroupNoFields() throws Exception { try { Group testGroup = identityService.newGroup("testgroup"); testGroup.setName("Test group"); testGroup.setType("Test type"); identityService.saveGroup(testGroup); ObjectNode requestNode = objectMapper.createObjectNode(); HttpPut httpPut = new HttpPut(SERVER_URL_PREFIX + RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, "testgroup")); httpPut.setEntity(new StringEntity(requestNode.toString())); CloseableHttpResponse response = executeRequest(httpPut, HttpStatus.SC_OK); JsonNode responseNode = objectMapper.readTree(response.getEntity().getContent()); closeResponse(response); assertNotNull(responseNode); assertEquals("testgroup", responseNode.get("id").textValue()); assertEquals("Test group", responseNode.get("name").textValue()); assertEquals("Test type", responseNode.get("type").textValue()); assertTrue(responseNode.get("url").textValue().endsWith(RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP, testGroup.getId()))); Group createdGroup = identityService.createGroupQuery().groupId("testgroup").singleResult(); assertNotNull(createdGroup); assertEquals("Test group", createdGroup.getName()); assertEquals("Test type", createdGroup.getType()); } finally { try { identityService.deleteGroup("testgroup"); } catch (Throwable ignore) { // Ignore, since the group may not have been created in the test // or already deleted } } }
Example 18
Source File: DemoDataGenerator.java From maven-framework-project with MIT License | 5 votes |
protected void createGroup(String groupId, String type) { if (identityService.createGroupQuery().groupId(groupId).count() == 0) { Group newGroup = identityService.newGroup(groupId); newGroup.setName(groupId.substring(0, 1).toUpperCase() + groupId.substring(1)); newGroup.setType(type); identityService.saveGroup(newGroup); } }
Example 19
Source File: GroupCollectionResourceTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
/** * Test getting all groups. */ @Deployment public void testGetGroups() throws Exception { List<Group> savedGroups = new ArrayList<Group>(); try { Group group1 = identityService.newGroup("testgroup1"); group1.setName("Test group"); group1.setType("Test type"); identityService.saveGroup(group1); savedGroups.add(group1); Group group2 = identityService.newGroup("testgroup2"); group2.setName("Another group"); group2.setType("Another type"); identityService.saveGroup(group2); savedGroups.add(group2); Group group3 = identityService.createGroupQuery().groupId("admin").singleResult(); assertNotNull(group3); // Test filter-less String url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION); assertResultsPresentInDataResponse(url, group1.getId(), group2.getId(), group3.getId()); // Test based on name url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?name=" + encode("Test group"); assertResultsPresentInDataResponse(url, group1.getId()); // Test based on name like url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?nameLike=" + encode("% group"); assertResultsPresentInDataResponse(url, group2.getId(), group1.getId()); // Test based on type url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?type=" + encode("Another type"); assertResultsPresentInDataResponse(url, group2.getId()); // Test based on group member url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?member=kermit"; assertResultsPresentInDataResponse(url, group3.getId()); // Test based on potentialStarter String processDefinitionId = repositoryService.createProcessDefinitionQuery().processDefinitionKey("simpleProcess").singleResult().getId(); repositoryService.addCandidateStarterGroup(processDefinitionId, "admin"); url = RestUrls.createRelativeResourceUrl(RestUrls.URL_GROUP_COLLECTION) + "?potentialStarter=" + processDefinitionId; assertResultsPresentInDataResponse(url, group3.getId()); } finally { // Delete groups after test passes or fails if (!savedGroups.isEmpty()) { for (Group group : savedGroups) { identityService.deleteGroup(group.getId()); } } } }
Example 20
Source File: IdentityTest.java From activiti6-boot2 with Apache License 2.0 | 4 votes |
public void testFindGroupsByUserAndType() { Group sales = identityService.newGroup("sales"); sales.setType("hierarchy"); identityService.saveGroup(sales); Group development = identityService.newGroup("development"); development.setType("hierarchy"); identityService.saveGroup(development); Group admin = identityService.newGroup("admin"); admin.setType("security-role"); identityService.saveGroup(admin); Group user = identityService.newGroup("user"); user.setType("security-role"); identityService.saveGroup(user); User johndoe = identityService.newUser("johndoe"); identityService.saveUser(johndoe); User joesmoe = identityService.newUser("joesmoe"); identityService.saveUser(joesmoe); User jackblack = identityService.newUser("jackblack"); identityService.saveUser(jackblack); identityService.createMembership("johndoe", "sales"); identityService.createMembership("johndoe", "user"); identityService.createMembership("johndoe", "admin"); identityService.createMembership("joesmoe", "user"); List<Group> groups = identityService.createGroupQuery().groupMember("johndoe").groupType("security-role").list(); Set<String> groupIds = getGroupIds(groups); Set<String> expectedGroupIds = new HashSet<String>(); expectedGroupIds.add("user"); expectedGroupIds.add("admin"); assertEquals(expectedGroupIds, groupIds); groups = identityService.createGroupQuery().groupMember("joesmoe").groupType("security-role").list(); groupIds = getGroupIds(groups); expectedGroupIds = new HashSet<String>(); expectedGroupIds.add("user"); assertEquals(expectedGroupIds, groupIds); groups = identityService.createGroupQuery().groupMember("jackblack").groupType("security-role").list(); assertTrue(groups.isEmpty()); identityService.deleteGroup("sales"); identityService.deleteGroup("development"); identityService.deleteGroup("admin"); identityService.deleteGroup("user"); identityService.deleteUser("johndoe"); identityService.deleteUser("joesmoe"); identityService.deleteUser("jackblack"); }