org.visallo.core.model.workspace.WorkspaceRepository.findById()方法的使用及代码示例

x33g5p2x  于2022-02-03 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(147)

本文整理了Java中org.visallo.core.model.workspace.WorkspaceRepository.findById()方法的一些代码示例,展示了WorkspaceRepository.findById()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WorkspaceRepository.findById()方法的具体详情如下:
包路径:org.visallo.core.model.workspace.WorkspaceRepository
类名称:WorkspaceRepository
方法名:findById

WorkspaceRepository.findById介绍

暂无

代码示例

代码示例来源:origin: org.visallo/visallo-core

  1. @Override
  2. protected Workspace convert(String workspaceId) {
  3. if (workspaceId == null) {
  4. return null;
  5. }
  6. try {
  7. return findById(workspaceId, user);
  8. } catch (VisalloAccessDeniedException ex) {
  9. return null;
  10. }
  11. }
  12. };

代码示例来源:origin: org.visallo/visallo-core

  1. public abstract Workspace findById(String workspaceId, boolean includeHidden, User user);

代码示例来源:origin: org.visallo/visallo-core

  1. public void updateEntityOnWorkspace(
  2. String workspaceId,
  3. String vertexId,
  4. User user
  5. ) {
  6. Workspace workspace = findById(workspaceId, user);
  7. updateEntityOnWorkspace(workspace, vertexId, user);
  8. }

代码示例来源:origin: org.visallo/visallo-core

  1. public void updateEntitiesOnWorkspace(
  2. String workspaceId,
  3. Collection<String> vertexIds,
  4. User user
  5. ) {
  6. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  7. workspaceRepository.updateEntitiesOnWorkspace(workspace, vertexIds, user);
  8. workQueueRepository.pushUserCurrentWorkspaceChange(user, workspaceId);
  9. graph.flush();
  10. }

代码示例来源:origin: org.visallo/visallo-core-test

  1. @Test
  2. public void testFindByIdNotExists() {
  3. Workspace ws = getWorkspaceRepository().findById("workspaceNotExists", false, user);
  4. assertEquals(null, ws);
  5. }

代码示例来源:origin: org.visallo/visallo-core-test

  1. @Test
  2. public void testPushWorkspaceChangeDifferentUser() {
  3. ClientApiWorkspace clientApiWorkspace = new ClientApiWorkspace();
  4. clientApiWorkspace.setWorkspaceId("ws1");
  5. List<ClientApiWorkspace.User> previousUsers = new ArrayList<>();
  6. ClientApiWorkspace.User previousUser = new ClientApiWorkspace.User();
  7. previousUser.setUserId("mockUser1");
  8. previousUsers.add(previousUser);
  9. String changedByUserId = "mockUser2";
  10. String changedBySourceGuid = "123-123-1234";
  11. Authorizations mockUser1Auths = graph.createAuthorizations("mockUser1Auths");
  12. when(userRepository.findById(changedByUserId)).thenReturn(mockUser2);
  13. when(workspaceRepository.findById(eq("ws1"), eq(mockUser2))).thenReturn(workspace);
  14. when(userRepository.findById(eq("mockUser1"))).thenReturn(mockUser1);
  15. when(authorizationRepository.getGraphAuthorizations(eq(mockUser1), eq("ws1"))).thenReturn(mockUser1Auths);
  16. when(workspaceRepository.toClientApi(eq(workspace), eq(mockUser1), any())).thenReturn(clientApiWorkspace);
  17. workQueueRepository.pushWorkspaceChange(clientApiWorkspace, previousUsers, changedByUserId, changedBySourceGuid);
  18. assertEquals(1, workQueueRepository.broadcastJsonValues.size());
  19. JSONObject json = workQueueRepository.broadcastJsonValues.get(0);
  20. assertEquals("workspaceChange", json.getString("type"));
  21. assertEquals("mockUser2", json.getString("modifiedBy"));
  22. assertEquals(new JSONObject("{\"users\":[\"mockUser1\"]}").toString(), json.getJSONObject("permissions").toString());
  23. assertEquals(
  24. new JSONObject("{\"editable\":false,\"users\":[],\"commentable\":false,\"workspaceId\":\"ws1\",\"sharedToUser\":false}").toString(),
  25. json.getJSONObject("data").toString()
  26. );
  27. assertEquals("123-123-1234", json.getString("sourceGuid"));
  28. }

代码示例来源:origin: org.visallo/visallo-tools-import

  1. @Override
  2. protected int run() throws Exception {
  3. Workspace workspace;
  4. if (workspaceId == null) {
  5. workspace = null;
  6. } else {
  7. workspace = workspaceRepository.findById(workspaceId, getUser());
  8. }
  9. fileImport.importDirectory(dataDir, queueDuplicates, conceptTypeIRI, visibilitySource, workspace, priority, getUser(), getAuthorizations());
  10. return 0;
  11. }

代码示例来源:origin: org.visallo/visallo-web

  1. @Handle
  2. public ClientApiWorkspaceDiff handle(
  3. @ActiveWorkspaceId String workspaceId,
  4. FormulaEvaluator.UserContext userContext,
  5. User user
  6. ) throws Exception {
  7. Workspace workspace = workspaceRepository.findById(workspaceId, true, user);
  8. if (workspace == null) {
  9. throw new VisalloResourceNotFoundException("Cannot find workspace: " + workspaceId);
  10. }
  11. return this.workspaceRepository.getDiff(workspace, user, userContext);
  12. }
  13. }

代码示例来源:origin: org.visallo/visallo-web

  1. private void switchWorkspace(String authUserId, String workspaceId) {
  2. if (!workspaceId.equals(userRepository.getCurrentWorkspaceId(authUserId))) {
  3. User authUser = userRepository.findById(authUserId);
  4. Workspace workspace = workspaceRepository.findById(workspaceId, authUser);
  5. userRepository.setCurrentWorkspace(authUserId, workspace.getWorkspaceId());
  6. workQueueRepository.pushUserCurrentWorkspaceChange(authUser, workspace.getWorkspaceId());
  7. LOGGER.debug("User %s switched current workspace to %s", authUserId, workspaceId);
  8. }
  9. }

代码示例来源:origin: org.visallo/visallo-core

  1. protected void broadcastWorkspace(
  2. ClientApiWorkspace workspace,
  3. List<ClientApiWorkspace.User> previousUsers,
  4. String changedByUserId,
  5. String changedBySourceGuid
  6. ) {
  7. User changedByUser = getUserRepository().findById(changedByUserId);
  8. Workspace ws = getWorkspaceRepository().findById(workspace.getWorkspaceId(), changedByUser);
  9. previousUsers.forEach(workspaceUser -> {
  10. boolean isChangingUser = workspaceUser.getUserId().equals(changedByUserId);
  11. User user = isChangingUser ? changedByUser : getUserRepository().findById(workspaceUser.getUserId());
  12. Authorizations authorizations = getAuthorizationRepository().getGraphAuthorizations(user, workspace.getWorkspaceId());
  13. // No need to regenerate client api if changing user
  14. try {
  15. ClientApiWorkspace userWorkspace = isChangingUser ? workspace : getWorkspaceRepository().toClientApi(ws, user, authorizations);
  16. JSONObject json = new JSONObject();
  17. json.put("type", "workspaceChange");
  18. json.put("modifiedBy", changedByUserId);
  19. json.put("permissions", getPermissionsWithUsers(null, Arrays.asList(workspaceUser)));
  20. json.put("data", new JSONObject(ClientApiConverter.clientApiToString(userWorkspace)));
  21. json.putOpt("sourceGuid", changedBySourceGuid);
  22. broadcastJson(json);
  23. } catch (VisalloAccessDeniedException e) {
  24. /* Ignore push message if lost access */
  25. }
  26. });
  27. }

代码示例来源:origin: org.visallo/visallo-web

  1. @Handle
  2. public ClientApiSuccess handle(
  3. @Required(name = "workspaceId") String workspaceId,
  4. User user,
  5. Authorizations authorizations
  6. ) throws Exception {
  7. LOGGER.info("Deleting workspace with id: %s", workspaceId);
  8. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  9. if (workspace == null) {
  10. throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
  11. }
  12. ClientApiWorkspace clientApiWorkspaceBeforeDeletion = workspaceRepository.toClientApi(workspace, user, authorizations);
  13. workspaceRepository.delete(workspace, user);
  14. workQueueRepository.pushWorkspaceDelete(clientApiWorkspaceBeforeDeletion);
  15. return VisalloResponse.SUCCESS;
  16. }
  17. }

代码示例来源:origin: org.visallo/visallo-web

  1. Workspace workspace = workspaceRepository.findById(workspaceId, user);

代码示例来源:origin: org.visallo/visallo-web

  1. @Handle
  2. public ClientApiWorkspace handle(
  3. @Required(name = "workspaceId") String workspaceId,
  4. User user,
  5. Authorizations authorizations
  6. ) throws Exception {
  7. LOGGER.info("Attempting to retrieve workspace: %s", workspaceId);
  8. try {
  9. final Workspace workspace = workspaceRepository.findById(workspaceId, user);
  10. if (workspace == null) {
  11. throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
  12. } else {
  13. LOGGER.debug("Successfully found workspace");
  14. return workspaceRepository.toClientApi(workspace, user, authorizations);
  15. }
  16. } catch (SecurityVertexiumException ex) {
  17. throw new VisalloAccessDeniedException("Could not get workspace " + workspaceId, user, workspaceId);
  18. }
  19. }
  20. }

代码示例来源:origin: org.visallo/visallo-web-product-graph

  1. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  2. ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);

代码示例来源:origin: org.visallo/visallo-web-plugins-admin-user-tools

  1. @Handle
  2. public ClientApiSuccess handle(
  3. @Required(name = "workspaceId") String workspaceId,
  4. @Required(name = "user-name") String userName,
  5. User me
  6. ) throws Exception {
  7. User user = userRepository.findByUsername(userName);
  8. if (user == null) {
  9. throw new VisalloResourceNotFoundException("Could not find user: " + userName);
  10. }
  11. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  12. if (workspace == null) {
  13. throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
  14. }
  15. workspaceRepository.updateUserOnWorkspace(workspace, me.getUserId(), WorkspaceAccess.WRITE, user);
  16. return VisalloResponse.SUCCESS;
  17. }
  18. }

代码示例来源:origin: org.visallo/visallo-web

  1. @Handle
  2. public ClientApiWorkspace handle(
  3. @Required(name = "data") ClientApiWorkspaceUpdateData updateData,
  4. @ActiveWorkspaceId String workspaceId,
  5. @SourceGuid String sourceGuid,
  6. ResourceBundle resourceBundle,
  7. User user,
  8. Authorizations authorizations
  9. ) throws Exception {
  10. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  11. if (workspace == null) {
  12. throw new VisalloResourceNotFoundException("Could not find workspace: " + workspaceId);
  13. }
  14. if (updateData.getTitle() != null) {
  15. setTitle(workspace, updateData.getTitle(), user);
  16. }
  17. updateUsers(workspace, updateData.getUserUpdates(), resourceBundle, user);
  18. workspace = workspaceRepository.findById(workspaceId, user);
  19. ClientApiWorkspace clientApiWorkspaceAfterUpdateButBeforeDelete = workspaceRepository.toClientApi(
  20. workspace,
  21. user,
  22. authorizations
  23. );
  24. List<ClientApiWorkspace.User> previousUsers = clientApiWorkspaceAfterUpdateButBeforeDelete.getUsers();
  25. deleteUsers(workspace, updateData.getUserDeletes(), user);
  26. ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);
  27. workQueueRepository.pushWorkspaceChange(clientApiWorkspace, previousUsers, user.getUserId(), sourceGuid);
  28. return workspaceRepository.toClientApi(workspace, user, authorizations);
  29. }

代码示例来源:origin: org.visallo/visallo-web

  1. Workspace workspace = this.workspaceRepository.findById(workspaceId, user);

代码示例来源:origin: org.visallo/visallo-web-product-graph

  1. graph.flush();
  2. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  3. ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);

代码示例来源:origin: org.visallo/visallo-web-product-graph

  1. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  2. ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);

代码示例来源:origin: org.visallo/visallo-web-product-graph

  1. Workspace workspace = workspaceRepository.findById(workspaceId, user);
  2. ClientApiWorkspace clientApiWorkspace = workspaceRepository.toClientApi(workspace, user, authorizations);

相关文章